LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Javascript and Radio Inputs. (https://www.linuxquestions.org/questions/programming-9/javascript-and-radio-inputs-320415/)

swatward 05-05-2005 11:44 AM

Javascript??
 
Why am i not able to get this to return the imput?
any help greatly appreciated.

Thanks,
Brad

P.S.Here is the file that im talking about
Code:

<html>
<head>


<title>Robots 4 Sale</title>
<script>
function calculate_total( bb)
{
document.write("Type: " + bb)
}
</script>
</head>

<body bgcolor="#708090">

<script language="JavaScript1.2">
if (document.all||document.getElementById)
document.body.style.background="url('bg.jpg') bottom right no-repeat fixed"
</script>


<center><marquee bgcolor=dodgerblue width=250 ><h1>ROBOTS!
<img src="images/1.jpg"><img src="1.jpg"><img src="1.jpg">
</h1></marquee></center>
<font face="Batang">

<p><br><br>
Domo Arigato Mr. Roboto. <br>
How many times have you wanted to not clean up your room, or do anything at all?
Do you remember the last time you wished you had a bodyguard or a helper robot?
<br>Well now you dont have to!<br>
</p>




  <form name="joes"><br>
  <input type="radio" name="bb" value="generic">Generic Robot<br>
  <input type="radio" name="bb" value="helper">Helper Robot<br>
  <input type="radio" name="bb" value="bodyguard">Body Guard<br>
  <input type="radio" name="bb" value="killer">Killer Robot <br>
  <input type="submit" name="submit" value="submit" onclick="calculate_total(joes.bb.value)">
  </form>





</font>
</body>
</html>


keefaz 05-06-2005 04:51 AM

Try to name your checkbox with an unique name, like bb1, bb2...

If you want to capture checkbox value, try :
Code:

<script>
global_type = "generic"; // default to generic
function update_type( type )
{
    global_type = type;
}
function calculate_total()
{
document.write("Type: " + global_type);
}
</script>
...
  <form name="joes"><br>
  <input type="radio" name="bb" value="generic" onclick="update_type(this.value)">Generic Robot<br>
  <input type="radio" name="bb" value="helper" onclick="update_type(this.value)">Helper Robot<br>
  <input type="radio" name="bb" value="bodyguard" onclick="update_type(this.value)">Body Guard<br>
  <input type="radio" name="bb" value="killer" onclick="update_type(this.value)">Killer Robot <br>
  <input type="submit" name="submit" value="submit" onclick="calculate_total();">
  </form>



All times are GMT -5. The time now is 07:05 AM.