Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用javascript向表单post url添加变量_Javascript_Jquery_Html - Fatal编程技术网

使用javascript向表单post url添加变量

使用javascript向表单post url添加变量,javascript,jquery,html,Javascript,Jquery,Html,在我的网站上,有一个新用户必须填写的表格,然后会向该用户发送一条短信。这就是表单操作的外观 http://example.com/app_api.php?view=send_sms&&user=username&&pass=password&&message=hello+there+welcome+to+our+group&&sender_id=example&

在我的网站上,有一个新用户必须填写的表格,然后会向该用户发送一条短信。这就是表单操作的外观

http://example.com/app_api.php?view=send_sms&&user=username&&pass=password&&message=hello+there+welcome+to+our+group&&sender_id=example&&to=00000000&&key=4
但是,由于每个用户的电话号码都不同,我想用用户将在text字段
phone
中输入的变量替换表单操作中的
to
变量

有人能帮我渡过难关吗

<form id="new_member_sms" name="new_member_sms" method="post" action="http://example.com/app_api.php?view=send_sms&amp;&amp;user=username&amp;&amp;pass=password&amp;&amp;message=hello+there+welcome+to+our+group&amp;&amp;sender_id=example&amp;&amp;to=00000000&amp;&amp;key=4">
  <label for="phone"></label>
  <blockquote>
    <p>
      <input name="phone" type="text" id="phone" />

    </p>
  </blockquote>
</form>



漂亮的trippy表单,通过POST发送,还包括通过操作的查询字符串获取变量,但这里有一个快速jquery解决方案,用于替换查询字符串中的电话号码:

<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.min.js"></script>
<script type="text/javascript">
$('#new_member_sms').submit(function(){
    var formAction = $(this).attr('action');
    var newAction = formAction.replace('00000000', $('#phone').val());
    $(this).attr('action', newAction);
});
</script>

$('#新成员_sms')。提交(函数(){
var formAction=$(this.attr('action');
var newAction=formAction.replace('00000000',$('#phone').val());
$(this.attr('action',newAction);
});

漂亮的trippy表单,通过POST发送,还包括通过操作的查询字符串获取变量,但这里有一个快速jquery解决方案,用于替换查询字符串中的电话号码:

<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.min.js"></script>
<script type="text/javascript">
$('#new_member_sms').submit(function(){
    var formAction = $(this).attr('action');
    var newAction = formAction.replace('00000000', $('#phone').val());
    $(this).attr('action', newAction);
});
</script>

$('#新成员_sms')。提交(函数(){
var formAction=$(this.attr('action');
var newAction=formAction.replace('00000000',$('#phone').val());
$(this.attr('action',newAction);
});