File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes How to pass value to JavaScript function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to pass value to JavaScript function" Watch "How to pass value to JavaScript function" New topic

How to pass value to JavaScript function

Travis Gibson
Ranch Hand

Joined: Oct 17, 2000
Posts: 100
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.

Regards,<BR>Travis M. Gibson, SCJP<BR>Java Developer<BR><BR>
kichu kichu
Ranch Hand

Joined: May 10, 2001
Posts: 59
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)
<script language="javascript">
function fun(str)
<form name="f1">
<input type="text" name="txt" size=20>
<input type="radio" name="r1" value="radio1" onClick="fun(document.f1.txt.value)">
[This message has been edited by kichu kichu (edited May 10, 2001).]
Connie Boyd
Ranch Hand

Joined: Feb 22, 2001
Posts: 73
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
I agree. Here's the link:
subject: How to pass value to JavaScript function
jQuery in Action, 3rd edition