|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Radio Buttons
hi - Ok - heres my problem.
Ive got a nonform modalDialog with radio buttons. I want to get the value in a string with the selected radio button. the code i tried just give out the first radio value and not the selected value. please help ! |
|
#2
|
||||
|
||||
|
RE: Radio Buttons
Why a nonform?
Could you post your code please. |
|
#3
|
|||
|
|||
|
RE: Radio Buttons
Code:
function GetSelected(){
radioSel = document.getElementById('Align').value;
alert(radioSel);
}
<input id="Align" type="radio" value="left" onClick="GetSelected()">
<input id="Align" type="radio" value="right" onClick="GetSelected()">
<input id="Align" type="radio" value="center" onClick="GetSelected()">
I want the code to alert() the value of the radio selected without submitting. is it even possable ? Thanks |
|
#4
|
||||
|
||||
|
RE: Radio Buttons
I don't know why it's not working. Not my area. But if you are using an OnClick - why don't you just pass in a value?
|
|
#5
|
||||
|
||||
|
RE: Radio Buttons
Try changing ID to be NAME - see if it helps
|
|
#6
|
|||
|
|||
|
RE: Radio Buttons
i tried name - and id together. still no good.
the only option i can think of is using a array indexing, therefore counting how many radio buttins i have and go through them until i find the checked = true.. |
|
#7
|
|||
|
|||
|
RE: Radio Buttons
Well, it isnt working, because you have more than one element with the same name, hence, the first defined variable is the one it is displaying. Try this: change the id's to name's, and then put a unique id name in the tag. For instance, <input type="radio" name="Align" id="align1" value="left">
Then you're going to need to rewrite that function: Code:
function GetSelected(id){
radioSel = document.getElementById(id).value;
alert(radioSel);
For your onClick's tag do this: (for example, my id is align1) <input type="radio" name="Align" id="align1" onClick="GetSelected('align1')"> PS: you need to keep the name identifier so that it switches in between the three buttons. |
|
#8
|
|||
|
|||
|
RE: RE: Radio Buttons
Quote:
Your're a genuis - cant believe i overlooked that one :p I used that very idea when making a docheck function ; i feel so small ! thanks again for all your help ! |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > Radio Buttons |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|