使用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&&user=username&&pass=password&&message=hello+there+welcome+to+our+group&&sender_id=example&&to=00000000&&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);
});