Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/362.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
Php 通过文本框值将单选按钮设置为真?_Php_Javascript - Fatal编程技术网

Php 通过文本框值将单选按钮设置为真?

Php 通过文本框值将单选按钮设置为真?,php,javascript,Php,Javascript,我需要在更改文本框中的值时选中单选按钮 radio button value 100.00rs input hidden array 10 clients radio button value 200.00 - 250.00rs input hidden array 30 clients radio button value 250.00 - 300.00rs input hidden arra

我需要在更改文本框中的值时选中单选按钮

radio button value 100.00rs                     input hidden array 10 clients     
radio button value 200.00 - 250.00rs            input hidden array 30 clients    
radio button value 250.00 - 300.00rs            input hidden array 50 clients    
radio button value 300.00 - 350.00rs            input hidden array 75 clients    
radio button value 350.00 - 400.00rs            input hidden array 100 clients    
这些值由mysql-php-foreach循环获取 当我使用javascript onchange函数更改textbox的值时,应根据该值选择单选按钮。 例如 如果在文本框中输入10,则应选择第一个单选按钮 否则,如果输入值介于200-250秒之间,则应选择单选按钮

function onChangeTest() {
var radio = document.getElementsByName("amt[1]") 
var qty2 = document.getElementsByName("max[]") 
var input = document.getElementById('ts').value;
    for(var i=0;i<radio.length;i++){
        if(input < qty2[i].value ){  // if input is < or between radio button value
        //document.getElementByName('amt[2]').checked = true;
        alert(radio[i].value + '\n' + qty2[i].value + '\n' +  input + '\n' + i) ; 
        }
    }

}
函数onChangeTest(){
var radio=document.getElementsByName(“金额[1]”)
var qty2=document.getElementsByName(“max[]”)
var输入=document.getElementById('ts')。值;

对于(var i=0;i,如果我正确理解了您的问题,您将询问如何通过文本字段检查单选按钮

基本上:

pseudocode
if text value == "true", then
    set radio button to true
这可以通过以下方式完成

HTML
<input type="text" id="txt">
<input type="radio" id="rad">

JAVASCRIPT
txt.onkeyup = function(){
    if(txt.value == 'true'){
        rad.checked = true;
    }else{
        rad.checked = false;
    }
}
HTML
JAVASCRIPT
txt.onkeyup=函数(){
如果(txt.value='true'){
rad.checked=true;
}否则{
rad.checked=false;
}
}

如果我没弄错你的问题,你是在问如何通过文本字段检查单选按钮

基本上:

pseudocode
if text value == "true", then
    set radio button to true
这可以通过以下方式完成

HTML
<input type="text" id="txt">
<input type="radio" id="rad">

JAVASCRIPT
txt.onkeyup = function(){
    if(txt.value == 'true'){
        rad.checked = true;
    }else{
        rad.checked = false;
    }
}
HTML
JAVASCRIPT
txt.onkeyup=函数(){
如果(txt.value='true'){
rad.checked=true;
}否则{
rad.checked=false;
}
}