我希望使用php回显textbox值。无论用户在文本框中输入要显示在另一个文本框中的字符,它都会以值的形式回显顶部的数量:(无论在文本框中键入什么),这里都是屏幕截图
以下是守则:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<?php
if(!empty($_GET['a1']))
{
$selected = $_GET['a1'];
}
else
{
$selected = 'home';
}
if(!empty($_GET['a1']))
{
$selected = $_GET['a1'];
}
else
{
$selected = 'home';
}
?>
<span class="r-text" style="font-weight:bold;">Value is</span>
<form action="" method="post">
<label>
<input type="radio" name="a1" value="100" /> 100
</label>
</br>
<label>
<input type="radio" name="a1" value="200" /> 200
</label>
</br>
<label>
<input type="radio" name="a1" value="300" /> 300
</label>
</br>
<label>
<input type="radio" name="a1" value=" " /> Other
</label>
</br>
<input type="text" name="a1"/>
<br/>
<br/>
Amount
<input type="text" name="a2" />
<br/>
<br/>
</form>
<script>
$('input[type=radio]').click(function(e) {//jQuery works on clicking radio box
var value = $(this).val(); //Get the clicked checkbox value
var check = $(this); //Get the clicked checkbox properties (like ID, value, class etc)
$('.r-text').html('Value is '+value);// The class r-text after clicked checkbox print the line 'This was selected'
});
</script>
<script>
$('input[type=text]').click(function(e) {//jQuery works on clicking radio box
var value = $(this).val(); //Get the clicked checkbox value
var check = $(this); //Get the clicked checkbox properties (like ID, value, class etc)
$('.r-text').html('Value is '+value);// The class r-text after clicked checkbox print the line 'This was selected'
});
</script>发布于 2017-12-11 09:38:11
当用户使用textarea.By事件键入另一个keyup时,可以在textarea中设置值。
$('input[type=text]').on("keyup",function(){
var value = parseInt($(this).val());
if($.isNumeric($("input[name='a1']:checked").val())){
value = parseInt($("input[name='a1']:checked").val()) +value;
}
$('[name="a2"]').val(value);
$(".r-text").html('Value is '+value);
})
$('input[type=radio]').on("change",function(){
var textBoxVal = parseInt($("input[type='text'][name='a1']").val());
var selectedVal = parseInt($("input[type='radio'][name='a1']:checked").val());
if(!$.isNumeric(textBoxVal)){
textBoxVal = 0;
}
if($.isNumeric(selectedVal )){
textBoxVal = parseInt(selectedVal) +textBoxVal;
}
$('[name="a2"]').val(textBoxVal);
$(".r-text").html('Value is '+textBoxVal);
})<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span class="r-text" style="font-weight:bold;">Value is</span>
<form action="" method="post">
<label>
<input type="radio" name="a1" value="100" /> 100
</label></br>
<label>
<input type="radio" name="a1" value="200" /> 200
</label></br>
<label>
<input type="radio" name="a1" value="300" /> 300
</label></br>
<label>
<input type="radio" name="a1" value=" " /> Other
</label></br>
<input type="text" name="a1"/><br/><br/>
Amount
<input type="text" name="a2" /><br/><br/>
</form>
发布于 2017-12-11 09:36:36
在包含用户输入的文本框上使用onKeyup事件。并填写所需的文本框。
发布于 2017-12-11 11:00:21
您可以从HTML标记中使用onblur()函数。onblur()是一个JavaScript函数。显示此函数中文本框的内容。
https://stackoverflow.com/questions/47749830
复制相似问题