在我的网站上有一个表单,新用户必须填写,然后将文本消息发送给用户。这就是表单操作的外观
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
但由于每个用户的电话号码不同,我想将表单操作中的to
变量替换为用户将在文本字段中输入的phone
任何人都可以帮助我完成
<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>
答案 0 :(得分:0)
通过POST发送相当简陋的表单,并且还通过操作的查询字符串包含GET变量,但这里是一个快速的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>