473,699 Members | 2,607 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to choose an event to trigger for many radio buttons?

hi,

i have some 10 radio buttons meant to take the rating from the user.
ex:

1 2 3 4 5 6 7 8 9 10
looks O O O O O O O O O O

1 2 3 4 5 6 7 8 9 10
features O O O O O O O O O O
..........
..........
..........

total score |______________ |

submit button |_______|

the user has to select any one for each row (looks, features etc).
I have to calculate the total % of his rating.

leaving "looks" blank, he cannot go to the next( "features", in this
case) and so on. if he has left "looks" unchosen and tries to check
"features", i should prompt him until he checks a radio button in
"looks".

how can i do this?? on what event should i call a function that does
this??

please help

thanks in advance.

Regards,

Amith
Jul 20 '05 #1
6 5186
Given my limited skills, this is what I would do...

Have the HTML for the "features" <radio> buttons be disabled
<input type="radio" name="features" value="1" disabled>
<input type="radio" name="features" value="2" disabled>
<input type="radio" name="features" value="3" disabled>
<input type="radio" name="features" value="4" disabled>

Then, in the onclick event for "looks", make all the "features" enabled
<input type="radio" name="looks" value="1" onclick="clickL ooks">
<input type="radio" name="looks" value="2" onclick="clickL ooks">
<input type="radio" name="looks" value="3" onclick="clickL ooks">
<input type="radio" name="looks" value="4" onclick="clickL ooks">

function clickLooks() {
var nlRadios
nlRadios = document.getEle mentsByName("lo oks")
for (i=0 ; i<nlRadios.leng th ; i++) {
nlRadios[i].disabled = false;
}
}

I wrote this off the top of my head, so you might have to change it somewhat
to get it to work, but you should get the idea

Mike

"amith" <it*******@yaho o.co.in> wrote in message
news:90******** *************** ***@posting.goo gle.com...
hi,

i have some 10 radio buttons meant to take the rating from the user.
ex:

1 2 3 4 5 6 7 8 9 10
looks O O O O O O O O O O

1 2 3 4 5 6 7 8 9 10
features O O O O O O O O O O
..........
..........
..........

total score |______________ |

submit button |_______|

the user has to select any one for each row (looks, features etc).
I have to calculate the total % of his rating.

leaving "looks" blank, he cannot go to the next( "features", in this
case) and so on. if he has left "looks" unchosen and tries to check
"features", i should prompt him until he checks a radio button in
"looks".

how can i do this?? on what event should i call a function that does
this??

please help

thanks in advance.

Regards,

Amith

Jul 20 '05 #2
You'd probably need an onClick event for each of the buttons in the
features group. E.g. (assuming the form is called "formname" and the
radio group is called "looks")

function checkLook(aRadi oButton) {
var isChecked = false;
for (i = 0; i < document.formna me.looks.length ; i++) {
if (document.formn ame.looks[i].checked) isChecked = true;
}
if (!isChecked) {
alert("Please rate the looks first!");
aRadioButton.ch ecked = false;
}
}

Then for each of the buttons in the features group, you'd do:

<INPUT TYPE="radio" NAME="features" VALUE="1"
onClick="checkL ook(this)">
<INPUT TYPE="radio" NAME="features" VALUE="2"
onClick="checkL ook(this)">

etc.

I haven't tested this, but you can try it out and tweak it.

it*******@yahoo .co.in (amith) wrote in message news:<90******* *************** ****@posting.go ogle.com>...
hi,

i have some 10 radio buttons meant to take the rating from the user.
ex:

1 2 3 4 5 6 7 8 9 10
looks O O O O O O O O O O

1 2 3 4 5 6 7 8 9 10
features O O O O O O O O O O
..........
..........
..........

total score |______________ |

submit button |_______|

the user has to select any one for each row (looks, features etc).
I have to calculate the total % of his rating.

leaving "looks" blank, he cannot go to the next( "features", in this
case) and so on. if he has left "looks" unchosen and tries to check
"features", i should prompt him until he checks a radio button in
"looks".

how can i do this?? on what event should i call a function that does
this??

please help

thanks in advance.

Regards,

Amith

Jul 20 '05 #3
I can't help with code but I would have thought the way to go is to have
user see only the first bit.
User fills it in and presses 'next' and the page refreshes to show the next
bit or gives and error if not filled in.

R
"Daniel Orner" <ci******@rpgcl assics.com> wrote in message
news:77******** *************** ***@posting.goo gle.com...
You'd probably need an onClick event for each of the buttons in the
features group. E.g. (assuming the form is called "formname" and the
radio group is called "looks")

function checkLook(aRadi oButton) {
var isChecked = false;
for (i = 0; i < document.formna me.looks.length ; i++) {
if (document.formn ame.looks[i].checked) isChecked = true;
}
if (!isChecked) {
alert("Please rate the looks first!");
aRadioButton.ch ecked = false;
}
}

Then for each of the buttons in the features group, you'd do:

<INPUT TYPE="radio" NAME="features" VALUE="1"
onClick="checkL ook(this)">
<INPUT TYPE="radio" NAME="features" VALUE="2"
onClick="checkL ook(this)">

etc.

I haven't tested this, but you can try it out and tweak it.

it*******@yahoo .co.in (amith) wrote in message

news:<90******* *************** ****@posting.go ogle.com>...
hi,

i have some 10 radio buttons meant to take the rating from the user.
ex:

1 2 3 4 5 6 7 8 9 10
looks O O O O O O O O O O

1 2 3 4 5 6 7 8 9 10
features O O O O O O O O O O
..........
..........
..........

total score |______________ |

submit button |_______|

the user has to select any one for each row (looks, features etc).
I have to calculate the total % of his rating.

leaving "looks" blank, he cannot go to the next( "features", in this
case) and so on. if he has left "looks" unchosen and tries to check
"features", i should prompt him until he checks a radio button in
"looks".

how can i do this?? on what event should i call a function that does
this??

please help

thanks in advance.

Regards,

Amith

Jul 20 '05 #4
Mike wrote:
Have the HTML for the "features" <radio> buttons be disabled
<input type="radio" name="features" value="1" disabled>
<input type="radio" name="features" value="2" disabled>
<input type="radio" name="features" value="3" disabled>
<input type="radio" name="features" value="4" disabled>
That is a generally a bad idea. What about users without JavaScript?
It is much better to have the radio buttons disabled by JavaScript (if
it is supported) when the document has been loaded (in the `onload'
event handler of the `body' element):

<body ... onload="disable RadioButtons(na me)">

The called function could be the code of the below clickLooks() with
adding having a named argument to define the value that should be assigned:

function disableRadioBut tons(bDisable)
{
... = !!bDisable;
}

The double negation (!!) makes bDisable like an optional argument
since it always returns a boolean value. If bDisable is not provided,
`undefined', `null' aso. or `false', !!bDisable evaluates to `false'.

In the above event handler you would pass `true', a numeric value other
than 0 or a reference to an object. (Probably the first one or `1' :-))
Then, in the onclick event for "looks", make all the "features" enabled
<input type="radio" name="looks" value="1" onclick="clickL ooks">
<input type="radio" name="looks" value="2" onclick="clickL ooks">
<input type="radio" name="looks" value="3" onclick="clickL ooks">
<input type="radio" name="looks" value="4" onclick="clickL ooks">
clickLooks without parantheses as call operator is nothing but a
function statement. To make it a function call, write clickLooks().
function clickLooks() {
var nlRadios
It is good practice to end JavaScript statements with `;'.
nlRadios = document.getEle mentsByName("lo oks")
Besides,

var nlRadios = ...

does the trick, too. And you should check, as with any other object
and property, if document.getEle mentsByName is supported before you use
it:

if (document.getEl ementsByName)
... document.getEle mentsByName(... ) ...

---> http://pointedears.de.vu/scripts/test/whatami

But you do not need the methods here.

var nlRadios = document.forms[...].elements["looks"];

will do the trick and it is both upwards and downwards compatible, where
`...' is the zero-based index of the form or the value of its `name' or
`id' attribute.
for (i=0 ; i<nlRadios.leng th ; i++) {
The counter variable is declared global here as the `var' keyword
is missing before it. That is bad style as it produces undesired
side effects, thus always use

for (var i = 0; i < nlRadios.length ; i++)
{
// ...
}
nlRadios[i].disabled = false;
Note that if the `disabled' property is not supported,
but either nothing happens or you get script errors.
It is best to check it before:

if (typeof nlRadios[i].disabled != "undefined" )
...
}
}

I wrote this off the top of my head, so you might have to change it somewhat
to get it to work, but you should get the idea
HTH
[Top post]


Please read and follow <http://www.netmeister. org/news/learn2quote2.ht ml>

Besides, please remove the REMOVETHIS part of your `From:' header.
The sender's e-mail address must be valid and munging addresses is
a Bad Thing, most certainly forbidden by the rules of your Usenet
provider. There are other ways to get rid of spam that do not
annoy people that want to communicate with you, possibly providing
useful off-topic information.
PointedEars
Jul 20 '05 #5
JRS: In article <3F************ **@PointedEars. de>, seen in
news:comp.lang. javascript, Thomas 'PointedEars' Lahn
<Po*********@we b.de> posted at Wed, 26 Nov 2003 21:01:19 :-

Besides, please remove the REMOVETHIS part of your `From:' header.
The sender's e-mail address must be valid and munging addresses is
a Bad Thing, most certainly forbidden by the rules of your Usenet
provider. There are other ways to get rid of spam that do not
annoy people that want to communicate with you, possibly providing
useful off-topic information.

The address mb************* **@skypoint.com is of legitimate format,
and may be one which Mike has permission from the owners of skypoint.com
to use.

Mail to that address should go to skypoint.com, and they may have
arranged suitable treatment for *R*********@sky point.com ;
alternatively, Mike may have subscribed also to that address, in order
to keep his spam separate from the mail that is addressed as he asks.

Other than by communicating with skypoint, or with Mike, there is no way
in which you, as an outsider, can assess the situation reliably - and
you are known to know, or at least to have been told, that you have
failed to do so in my case.

Additionally, you cannot tell from his news article what anti-spam
methods are reasonably available to Mike. You can know only that he has
access to SuperNews using MSOE6; that implies nothing about how he
receives mail, and what processes he can reasonably be expected to
employ.

Mike's arrangements are, in fact, none of your business.
Under present circumstances it is unwise to provide an address in UseNet
News, particularly in headers, especially in From, for which delivery is
actually guaranteed - unless one has a permanently-operating high-
bandwidth connection to the Net, and is running appropriate software.

Indeed, given the capabilities of malware, it is unwise to allow the use
of a reliable E-address to any person in whose good faith and technical
ability one does not have complete confidence.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
Jul 20 '05 #6
Dr John Stockton wrote:
Thomas 'PointedEars' Lahn [...]:
Besides, please remove the REMOVETHIS part of your `From:' header.
The sender's e-mail address must be valid and munging addresses is
a Bad Thing, most certainly forbidden by the rules of your Usenet
provider. There are other ways to get rid of spam that do not
annoy people that want to communicate with you, possibly providing
useful off-topic information.
The address mb************* **@skypoint.com is of legitimate format,
and may be one which Mike has permission from the owners of
skypoint.com to use.


Correct, I oversaw the second SMTP server here. Sorry to Mike, my bad.

$ host -t mx skypoint.net
skypoint.com mail is handled by 50 ann.skypoint.ne t.
skypoint.com mail is handled by 100 minuet.skypoint .net.
$ telnet ann.skypoint.ne t smtp
Trying 199.86.32.19...
Connected to ann.skypoint.ne t.
Escape character is '^]'.
220 ann.skypoint.ne t ESMTP Sendmail 8.9.3/8.9.3; Thu, 27 Nov 2003
23:52:25 GMT
helo pointedears.de
250 ann.skypoint.ne t Hello [...], pleased to meet you
vrfy mb************* **@skypoint.com
252 Cannot VRFY user; try RCPT to attempt delivery (or try finger)
mail from:po******** *@web.de
250 po*********@web .de... Sender ok
rcpt to:mb********** *****@skypoint. com
550 mb************* **@skypoint.com... User unknown
quit
221 ann.skypoint.ne t closing connection
Connection closed by foreign host.
$ telnet minuet.skypoint .net smtp
Trying 199.86.32.2...
Connected to minuet.skypoint .net.
Escape character is '^]'.
220 minuet.skypoint .net ESMTP Sendmail 8.12.9/8.12.9; Thu, 27 Nov 2003
18:00:43 -0600 (CST)
helo pointedears.de
250 minuet.skypoint .net Hello [...], pleased to meet you
vrfy mb************* **@skypoint.com
252 2.5.2 Cannot VRFY user; try RCPT to attempt delivery (or try finger)
mail from:po******** *@web.de
250 2.1.0 po*********@web .de... Sender ok
rcpt to:mb********** *****@skypoint. com
250 2.1.5 mb************* **@skypoint.com... Recipient ok
quit
221 2.0.0 minuet.skypoint .net closing connection
Connection closed by foreign host.
$
Other than by communicating with skypoint, or with Mike, there is no
way in which you, as an outsider, can assess the situation reliably -
You are wrong.
Mike's arrangements are, in fact, none of your business.


http://www.interhack.net/pubs/munging-harmful/
PointedEars
Jul 20 '05 #7

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

Similar topics

2
18574
by: Matt | last post by:
I have radio buttons on a form, and when the user makes the selection, it will trigger the event and send the form to the web server and print the selected value. In Case 1, I just use submit button, without any event handling, and it works fine. However, in Case 2, which is what I am trying to do, it has the problem that even when the user clicks the button, it won't show the value automatically. But wait until user selects another...
1
3439
by: Robin Becker | last post by:
I have to make 2 from 6 radio buttons change the rest of a form and the remaining 4 to do the opposite change. I find that onchange differs between IE & Mozilla, but onclick appears at first sight to occur at the same time. Are there any gotcha's with radio buttons vs browsers? -- Robin Becker
4
11033
by: Jared | last post by:
Radio Button or Check Box and Event Procedures I need to insert either radio buttons or check boxes onto my form. I'm not sure which to use, or if there are other options. I am using the buttons to: if one is clicked, its corresponding information will become available on another document, if it's not clicked no information will be provided. If multiple buttons are clicked their information will available on the same document. I'm not...
2
1760
by: tshad | last post by:
I have 2 radio buttons: <asp:RadioButton ID="radDetail" GroupName="detailSummary" Text="Detail" checkedChanged="RadDetail_Clicked" runat="server" /> <asp:RadioButton ID="radSummary" GroupName="detailSummary" Text="Summary" checkedChanged="RadSummary_Clicked" runat="server" /> </p> I want to have RadDetail_Click or RadSummary_Click executed as soon as the radio button is clicked.
16
1719
by: marc_r_bertrand | last post by:
To all asp/db pros: The quiz code below works. But there is a problem when too many questions are answered (radio buttons clicked). I am not an asp pro. So, is there a pro out there or an amateur guru who will be so kind as to volunteer some time to figure out where the bug is? This may mean he will have to go through the tedious steps of creating an .mdb with a few records...unless the bug is obvious... On a page with server-code...
19
4753
by: Daniela Roman | last post by:
Hello, I try to fire an event under a button click event and maybe anybody can give a clue please. I have let's say a WEB grid with PageIndexChanged event: private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
3
2452
by: Andreas Wöckl | last post by:
HI Group! I have to programmatically create a user input form with various Checkbox and RadioButton lists - Beside every List I have to place an image button that is able to reset the checkboxlists and radiobutton lists. if i declare a variable with private withEvents img as ImageButton
1
3072
rrocket
by: rrocket | last post by:
I have a page with radio buttons that either enable or disable textboxes depending on the radio button selection. When the user clicks submit the they are taken to a thank you page, but if they hit the back button on the browser the radio buttons both return false and the correct boxes are not disabled... Is there a way to trigger a function or store what boxes are diabled? I tried clearing everything just before the redirect as a quick...
1
4079
by: sourcie | last post by:
I am changing an existing quiz found on "JavaScriptKit.com Multiple Choice Quiz" I have an image. Instead of using the radio buttons with the normal true/false question, I want to place two hotspots on the image. One being correct(a) and the other incorrect(b). When the user clicks on the correct hotspot or place on the image, it should score and retain that value until the end of the quiz. At the end of the quiz, there is a submit button...
0
8706
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9199
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9055
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8902
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7787
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5891
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4392
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2366
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2016
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.