473,545 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

transferring value of radiobutton

<form name=form1>
Load in Viewer Window:
<input name="radiobutt on" type="radio" value="1" checked onClick="1">
1&nbsp;&nbsp;&n bsp;
<input type="radio" name="radiobutt on" value="2" onClick="2">
2&nbsp;&nbsp;&n bsp;
<input type="radio" name="radiobutt on" value="3" onClick="3">
3&nbsp;&nbsp;&n bsp;
<input type="radio" name="radiobutt on" value="4" onClick="4">
4
<input type=file name="fileN" size="75" >
<br>
<input type=submit onClick="setFil eMul(document.f orm1.radiobutto n.value)"
value="Load Selected File">
<font size="3"><stron g>Choose/Browse for sutiable Chime file
above</strong></font>
</form>

I am trying to get setFileMul( ) to pick which number radiobutton has been
checked. If I put a number such as setFileMul(2), the function works fine. What
do I need to put which radiobutton number has been checked in setFileMul(_)?

I though document.form1. radiobutton.val ue would have done the job.

Thanks,
Jeff

Jul 20 '05 #1
2 1859
On 11 Feb 2004 18:51:25 GMT, JeffFinnan <je********@aol .com> wrote:
I am trying to get setFileMul( ) to pick which number radiobutton has
been checked. If I put a number such as setFileMul(2), the function
works fine. What do I need to put which radiobutton number has been
checked in setFileMul(_)?

I though document.form1. radiobutton.val ue would have done the job.


Almost: document.form1. radiobutton will return a collection of all form
controls with the name "radiobutto n", not the currently selected element.
Try:

<input type="submit" value="Load Selected File"
onClick="setFil eMul(getOrdinal (this.form.radi obutton))">
...
function getOrdinal( buttonGroup ) {
var groupSize = buttonGroup.len gth;

for( var i = 0; i < groupSize; ++i ) {
if( buttonGroup[ i ].checked ) return buttonGroup[ i ].value;
}
}

Be aware that the function above, getOrdinal, returns a string, not a
number (the value attribute is of type string).

Mike

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #2
>Try:

<input type="submit" value="Load Selected File"
onClick="setFil eMul(getOrdinal (this.form.radi obutton))">
...
function getOrdinal( buttonGroup ) {
var groupSize = buttonGroup.len gth;

for( var i = 0; i < groupSize; ++i ) {
if( buttonGroup[ i ].checked ) return buttonGroup[ i ].value;
}
}

Be aware that the function above, getOrdinal, returns a string, not a
number (the value attribute is of type string).


==============
Mike,

That did the trick. It did not seem to matter whether it was string or not.

Thanks much,
Jeff
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2834
by: VK | last post by:
Hi! What I'm missing in following code? Cannot get the values of radiobuttons. Starting only one class (GetVariant), it works. When I put two classes together, it doesn't. Regards, VK from Tkinter import * class GetVariant: def __init__(self): self.root = Tk()
1
3831
by: R.G. Vervoort | last post by:
I would like to make a script wich makes a select visible or not visible depending on what radio button is selected. If the radiobutton with the value "nieuw" is selected the pulldown is not visible and when i select the radiobutton with the value "verwijderen" the pulldown should become visible. The code i have makes the pull down...
1
16614
by: LRW | last post by:
Below is some of the code I'm using. I have a PHP page generating a list of items. I've made it so that each one has a radiobutton with a unique value. You can click on the radiobutton and it will change the value of a text field to the value of the radiobutton--all that works fine! Now, I need to also have it populate a textfield with the...
1
3374
by: MickG | last post by:
I am trying to change the value of the variable "hard" according to which radio button is pressed and I am having no joy. Could anyone help me with this, the problematic section is marked with ***********************, I've included all the code incase that isn't where the problem is. Any help would be hugely appreciated. Mick
4
1384
by: darrel | last post by:
I have a contact form that a person submits to the server. In ASP, you'd make a page, post the form to another page, which would grab the values and do somethign with them. in ASP.NET, it appears that you grab the values directly from the form objects on the postback. Here's our problem:
2
5414
by: Rob | last post by:
Hi all, I've got multiple sets of radio button that are dynamically created in code and populated by a database query. The query returns about 20 recordsets with 3 radio buttons per recordset and I want to be able to retrieve the selected value from each of the sets of radio buttons.The names of each group of radio buttons is set by the...
2
6597
by: Rich | last post by:
Hello, Is it possible to assign a value to a groupbox by selecting a radiobutton contained in the groupbox? Say you assign a value of 1 to radbtn1, 2 for radbtn2, 3 for radbtn3 all contained in grpBox. You click radbtn1. Console.writeline(grpBox.Value.ToString)
0
1289
by: Nathan Sokalski | last post by:
In the RadioButton and CheckBox controls, there is no Value attribute. The html <inputtag has a value attribute, which is used by both type="radio" and type="checkbox". The RadioButtonList and CheckBoxList controls have SelectedValue properties (I realize that the RadioButtonList uses the <selectand <optiontags instead of the <inputtag, but...
12
24779
by: ive1122 | last post by:
Hi guys, I am looking into create a dynamic survey as posted in Get User Input From Dynamic Controls but with some different environment Below is what i am trying to do: First when the user click the button, it will populate a dynamic table with radio button for the survey questionnaire However, i was unable to get its value (for score...
0
7478
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7410
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7668
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7923
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7437
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
3466
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1901
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1025
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.