Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript getElementBy
    primarykey
    data
    text
    <p>I have a problem to detect the option selection where instead of using getElementById i want to use getElementByValue.Does it exist?? this is my code</p> <pre><code> &lt;script type="text/javascript"&gt; var total; function oneway(){ document.getElementById("return_date").style.visibility = "hidden"; document.getElementById("return_time").style.visibility = "hidden"; } function return_way(){ document.getElementById("return_date").style.visibility = "visible"; document.getElementById("return_time").style.visibility = "visible"; } function state_price(){ var way=document.getElementById("direction").value; var placefrom = document.getElementById("state_from").value; var placeto = document.getElementById("state_to").value; if (direction == "oneway"){ if ((placefrom=="Batu Pahat" &amp;&amp; placeto=="Alor Setar") ||(placefrom =="Alor Setar" &amp;&amp; placeto=="Batu Pahat")){ total=55.00; document.booking.total_price.value = total; }else if ((placefrom=="Batu Pahat" &amp;&amp; placeto=="Bachok")||(placefrom=="Bachok" &amp;&amp; placeto=="Batu Pahat")) { total=60.00; document.booking.total_price.value = total; }else if ((placefrom=="Batu Pahat" &amp;&amp; placeto=="A Famosa") || (placefrom=="A Famosa" &amp;&amp; placeto=="Batu Pahat")) { total=65.50; document.booking.total_price.value = total; }else if ((placefrom=="Batu Pahat" &amp;&amp; placeto=="Bahau")||(placefrom=="Bahau" &amp;&amp; placeto=="Batu Pahat")) { total=70.00; document.booking.total_price.value = total; }else if ((placefrom=="Batu Pahat" &amp;&amp; placeto=="Bentong") ||(placefrom=="Bentong" &amp;&amp; placeto=="Batu Pahat")) { total=75.50; document.booking.total_price.value = total; }else if ((placefrom=="Batu Pahat" &amp;&amp; placeto=="Kubang Kerian") ||(placefrom=="Kubang Kerian" &amp;&amp; placeto=="Batu Pahat")) { total=80.00; document.booking.total_price.value = total; } else { document.booking.txttotal.value = "Fail"; window.alert("Please enter a different destination"); } } else { ///something else } } &lt;/script&gt; </code></pre> <p>and this is the part of my html coding</p> <pre><code> &lt;tr &gt; &lt;td&gt;Travel Direction:&lt;/td&gt; &lt;td &gt; &lt;input type="radio" name ="direction" value = "oneway" onclick = "oneway()"/&gt;One Way &lt;input type="radio" name ="direction" value = "return" onclick = "return_way()"/&gt;Return &lt;/td&gt; &lt;/tr&gt; </code></pre> <p>i don't want to use the name as i'm using it in my php coding.so i don;t want to use it.Is there any way where i can do my javascript as i mentioned above (getElementByValue)?Thank You in advance</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload