单选按钮在JavaScript中更改变量

单选按钮在JavaScript中更改变量,javascript,html,Javascript,Html,我有两个字段来计算总数,但我有一个单选按钮对,它决定了方程中的一个变量。以下是单选按钮代码: <input type="radio" name="estimate_pool_shape" value="1" /> Angle <input type="radio" name="estimate_pool_shape" value=".86392" /> Freeform var估计值\u池\u形状=0;//或者一些默认值。也许一个? 对于(var i=0;i

我有两个字段来计算总数,但我有一个单选按钮对,它决定了方程中的一个变量。以下是单选按钮代码:

<input type="radio" name="estimate_pool_shape" value="1" /> Angle
<input type="radio" name="estimate_pool_shape" value=".86392" /> Freeform
var估计值\u池\u形状=0;//或者一些默认值。也许一个?
对于(var i=0;i

应该能满足您的需要。

((mainform.estimate\u pool\u width.value)+(mainform.estimate\u pool\u length.value)*(mainform.estimate\u pool\u shape.value))错误超出行,此处为%%%单选按钮变量%%%,然后将此处为%%%单选按钮变量%%%替换为估算值_pool_shapeRENAN到目标字段抱歉,我在上面的代码中犯了一些错误,我将对其进行编辑,使其正确。
    (Length <input type="text" size="5" name="estimate_pool_length" 
onBlur="conv2inches(document.forms.mainform);" />) x 
    (Width <input type="text" name="estimate_pool_width" size="5" 
onBlur="conv2inches(document.forms.mainform);" />)
        function conv2inches(mainform) {            

        var oin;    
        var oinches;

        if(isNaN(mainform.estimate_pool_width.value)||isNaN(mainform.estimate_pool_length.value)){  
            alert("Please enter numbers only"); 
            return false;   
        }

        oin = ((mainform.estimate_pool_width.value) + (mainform.estimate_pool_length.value) * %%%RADIO BUTTON VARIABLE HERE%%%);    
        oinches = (oin);    

        if(oinches==0){ 
            alert("Please enter valid values into the boxes");  
        }   
            mainform.estimate_pool_sqft.value = oinches;    
            return false;
        }
var estimate_pool_shape = 0; // Or some default value.  Maybe 1?
for(var i = 0; i < mainform.estimate_pool_shape.length;i++){
 if(mainform.estimate_pool_shape[i].checked){
   estimate_pool_shape = mainform.estimate_pool_shape[i].value;
   break;
 }
}