2013-07-04 38 views
-2

我在單選按鈕上工作我需要在一個按鈕上填充六個文本框的值單擊我在js小提琴中顯示mu問題這裏是鏈接:http://jsfiddle.net/sKrhY/ Kindly help我在這個.one的東西,我想提一下,在檢查單選按鈕abc一個文本框出現在哪個用戶可以輸入值,點擊calculate按鈕這個值也應該顯示.plz幫我在這 這裏是我的代碼:如何在一個按鈕上填充多個文本框點擊php

<script type="text/javascript"> 
function toggle(value) 
{ 
if(value=='show') 
document.getElementById('mytext').style.visibility='visible'; 
else 
document.getElementById('mytext').style.visibility='hidden'; 
} 
</script> 
<script> 
function doCalc(){ 
    var input_value = parseInt(document.getElementById("value_input").value); 
    document.getElementById("value_output").value = 100 * input_value; 
     document.getElementById("value_output1").value = 100 * input_value; 
     document.getElementById("value_output2").value = 100 * input_value; 
     document.getElementById("value_output3").value = 100 * input_value; 
      document.getElementById("value_output4").value = 100 * input_value; 
      document.getElementById("value_output5").value = 100 * input_value; 
       document.getElementById("value_output6").value = 100 * input_value; 
    return false; 
}; 

document.getElementById("calc_button").onclick = doCalc; 
</script> 

<form method="POST" name="form1"> 
No of Units (kwh) Used :<input type="text" id="value_input" value="123"></input><br/> 
select your categaory 
<input type="radio" name="myradio" checked="checked" onclick="toggle('hide');" />domestic 
<input type="radio" name="myradio" checked="checked" onclick="toggle('show');">a 
<input type="radio" name="myradio" checked="checked" onclick="toggle('show');">b 
<input type="radio" name="myradio" checked="checked" onclick="toggle('show');">c 
connected loads(kwh) 
<input type="text" name="mytext" id="mytext"> 
    Actual <input type="text" id="value_output"></input><br/> 
    tax <input type="text" name="text2" id="value_output1" /> 
Elec <input type="text" name="text3" id="value_output2" /> 
Charges <input type="text" name="text4" id="value_output3" /> 
Amount <input type="text" name="text5" id="value_output4" /> 
Govt <input type="text" name="text6" id="value_output5" /> 
result <input type="text" name="text7" id="value_output6" /> 
    <input id="calc_button" type="submit" name="Calculate" value="Calculate"></input> 
</form> 
+0

填入其中??點擊計算它正在工作 –

+0

詳細說明。我無法理解與價值觀您的問題 – Kris

+0

填入文本框一樣,如果用戶在使用,然後在單擊按鈕計算所有六個文本框是實際導致被填充300 – ashy1234

回答

0

根據您的評論,您需要將輸入數字乘以100 對於這個:

document.getElementById("value_output").value = 100 + input_value; 

value_output像value_outpu1,2,3所有值與此替換,等等:

document.getElementById("value_output").value = 100 * input_value; 

這裏是Fiddle

根據更新後的問題: 你是不是調用docalc() function.Try這樣的:

<form method="POST" name="form1" onsubmit="return doCalc();"> 
+0

先生,當我在我的網頁它不是在做這個代碼複製,但是,撥弄它的工作我做什麼:( – ashy1234

+0

不工作?你能如果現場提供的鏈接,或者嘗試找到在控制檯中的錯誤 –

+0

它沒有工作,當我複製此代碼 – ashy1234

0

爲了您的另一心願:
設定值radio按鈕

<input type="radio" value="100" name="myradio" checked="checked" onclick="toggle('hide');" />domestic 
<input type="radio" value="200" name="myradio" checked="checked" onclick="toggle('show');">a 

現在,你可以通過document.getElementByID('radio button id here')...得到的價值觀和你的公式是:

var radio_button_value = document.getElementById('').value; 
document.getElementById("value_output").value = radio_button_value * input_value; 
+0

在這裏我把這個代碼我不明白這個Java腳本的位置 – ashy1234

+0

PLZ幫我在這 – ashy1234

+0

就像你做了所有的Java腳本同樣的事情可以這一來發生過讀我的回答ADN告訴我,你所面對 –

相關問題