insideorkut.com

What's the best iContact email software out there for small business /img/avatar8.jpgs?

Try iContact email marketing for free for 30 days. Click here to use coupon...

Get a free trial of iContact here. Click here for this special deal...
Question I have... What's the best iContact email software out there for small business /img/avatar8.jpgs? Thanks for any response. Another question I got... Hi:.

I have a iContact site where there are 2 radio buttons and through Javascript I need to know which one was checked by the user, how can I retrieve that information??.

PLEASE HELP!!!..

Comments (9)

Hmm... I need to find out myself. I don't know what is the answer. I'll do some poking around and get back to you if I got an useful answer. You should email the people at iContact as they probably could give you help..

Comment #1

Sure, thx for the welcome!.

<form name="form1" >.

<p>.

<input name="r1" type="radio" >.

<input name="r1" type="radio" >.

<p>.

<input type="button" name="chequear" value="check" onClick="prueba()">.

</p>.

</form>.

</body>.

</html>.

I need to know which button was checked, I dunno if I need to use the ID property and in Javascript document.form1.r1.id.

Only one of these buttons can be checked, the thing is that depending which buttons was checked, different things happen...

Comment #2

As you didn't mention for which purpose you need to know it, I will assume that you know JavaScript well and can implement this code to your scripts. So, getting the checked option out of radio buttons is a little tricky. You could copy and paste this handy little function that I have written for the purpose:.

You give the function one argument, the name of the radio buttons in a radio button set, or the id of a radio button. It returns the checked value of the radio buttons, if none is checked, it returns null. I.e.:..

Comment #3

I cant meake it work.

This is my script:.

</head>.

<script language="JavaScript">.

Function getRadio(radioName){.

Var ret = null;.

Var inputs = document.getElementsByTagName('input');.

For(var I = 0; I < inputs.length; i++){.

If(inputs[i].type.toLowerCase() !== 'radio') next;.

If(inputs[i].name != radioName and inputs[i].id != radioName) next;.

If(inputs[i].checked) ret = inputs[i].value;.

}.

Return ret;.

}.

Var chosenValue = getRadio('gender');.

</script>.

<body>.

<form name="form1" >.

<p>.

<input type="radio" name="gender" value="male"> Male<br>.

<input type="radio" name="gender" value="female"> Female<br>.

<input type="radio" name="gender" value="n/a"> N/A<br>.

<p>.

<input type="button" name="chequear" value="check" onClick="getRadio(gender);">.

</p>.

</form>.

</body>.

</html>.

I cant spot the errors..

Comment #4

So apparently you don't know JavaScript that much. Then you will really need to explain what you want to do with the info you get from getRadio()...

Comment #5

I need it cuz once Im making a quiz and need to know how many questions were answered right..

By the way, I dont see how this could affect the script..

Comment #6

I'm not really sure about what you want; me to write the quiz script, to insert that code in your existing quiz script, or to simply advice how to use it. I did the thing I mentioned as last already; I told you how the function works, what arguments it takes and what it returns. Apparently you have not managed to use it correctly. How would you like me to help you, explain better maybe? Or insert it to your code? In that case, you will need to post the code...

Comment #7

What I needed was the code ,so thanks for that.But it doesnt seem to work.Ive made some changes but all the results I get are null(I change return ret for alert(ret) so as to check if it works fine)..

In my quiz I have multiple choice questions that have to be answered through radio buttons, thats why I need top know which one was selected,so I can compare the result with variables...

Comment #8

I'm very sorry. I have apparently been doing too much PERL coding lately... I seem to have not one, but actually two Perl references in my code; the.

And.

Operator that should be.

&&.

, and the.

Next.

That I cannot think the JavaScript correspondence for at the moment. Try this function instead, it is tested and works:.

Stupid me! I shouldn't be so confident about the code I post without testing it first... sorry again. I even have it stored on my computer, but noooooo, my code hungry fingers just demand to ratata on the keyboard!..

Comment #9

Thx, it work fine now, Ill let you know when I have my quiz finished and running..

Comment #10


This question was taken from a support group/message board and re-posted here so others can learn from it.