• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to pass value to JavaScript function

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here'smy problem. I am trying to pass a value set by a Radio button to a JavaScript function.
Can anyone help I sure there is a simple answer I just having trouble coming up with it.
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do u mean something of this sort--->Here after i type something into the text box and click the radio button,the value in the text box will be displayed in the alert message.
This alert message is inside a function called by the radio button.
Hope this is of use to u(If i have misunderstood your question,please explain it again)
<html>
<script language="javascript">
function fun(str)
{
alert(str);
}
</script>
<body>
<form name="f1">
<input type="text" name="txt" size=20>
<input type="radio" name="r1" value="radio1" onClick="fun(document.f1.txt.value)">
</form>
</body>
</html>
regards,
kichu.
[This message has been edited by kichu kichu (edited May 10, 2001).]
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you mean the actual value of the radio button, I think this should work:
<input type="radio" name="MyRadio" value="cool" onClick="myFunction(this.value)"> Cool
 
reply
    Bookmark Topic Watch Topic
  • New Topic