私は入力ボックスから値を受け取り、次のページまたはフォームに渡す単純なWebページを持っています。唯一の問題は、jquery
を使用して値を取得し、それをphp
値として割り当てる方法がわからないことです。ボタンをクリックし、それはどこにも行かないと何も値が私はURLjquery phpがテキストフィールドの値をURLに入れない
に表示されていない場合
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#usr").change(function(){
var usr = $("#usr").val();
$("#button").attr("href","calculate.php?id={45}&tt="+usr);
});
});
</script>
<?php
print
"<input type='text' class='form-control' id='usr'>".
"<a id='button' href='calculate.php?id={45}&tt='><button class='btn btn-success'>Calculate</button></a>";
?>
:私は、これは私の最新のコードIS URL
EDITにして、この値を渡したいです間違っている?
おかげ
'href'属性はボタン上で何もしません。それらは ''リンクでしか使用できません。 – Barmar
'button'のidに要素/タグがありません。 jqueryで '#button 'を取得していますが、存在しないので何も起こりません。また、通常、アンカー( ' ')タグ付きのボタンをラップすることはありません。 –
私はそれをボタンにリンクするにはどうすればいいですか?理想的には、テキストフィールドの値を使ってcalculate.phpページにリダイレクトしたいだけです。 –