473,406 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Alert box when radio button selected?

Is it possible to create an alert box when a radio button is selected? I
have a group of three, and I want a different alert for each one.
--
Nige

Please replace YYYY with the current year
ille quis mortem cum maximus ludos, vincat
Jul 20 '05 #1
8 10762
"Nige" <uY***@ntlworld.com> wrote in message
news:br********************************@4ax.com...
Is it possible to create an alert box when a radio button is selected? I
have a group of three, and I want a different alert for each one.


<form>
<input name="myradio" value="1" type="radio" onclick="alert(this.value)">
<input name="myradio" value="2" type="radio" onclick="alert(this.value)">
<input name="myradio" value="3" type="radio" onclick="alert(this.value)">
</form>
Jul 20 '05 #2
In comp.lang.javascript, Nige wrote:
Is it possible to create an alert box when a radio button is selected? I
have a group of three, and I want a different alert for each one.


Don't worry, sorted:

<input type="radio" name="sign" value="planningtosign"
onClick=alert('ABC')>
--
Nige

Please replace YYYY with the current year
ille quis mortem cum maximus ludos, vincat
Jul 20 '05 #3
In comp.lang.javascript, Nige wrote:
Is it possible to create an alert box when a radio button is selected? I
have a group of three, and I want a different alert for each one.


Don't worry, sorted:

<input type="radio" name="sign" value="planningtosign" onClick=alert('ABC')>


I spoke too soon.

It works providing there are no spaces in the string argument - help!
--
Nige

Please replace YYYY with the current year
ille quis mortem cum maximus ludos, vincat
Jul 20 '05 #4
In comp.lang.javascript, Nige wrote:
It works providing there are no spaces in the string argument


Thanks Vjekoslav, it needed quotes!
--
Nige

Please replace YYYY with the current year
ille quis mortem cum maximus ludos, vincat
Jul 20 '05 #5
@SM
Nige a ecrit :
In comp.lang.javascript, Nige wrote:
Is it possible to create an alert box when a radio button is selected? I
have a group of three, and I want a different alert for each one.

<input type="radio" name="sign" value="planningtosign" onClick=alert('ABC')>


I spoke too soon.

It works providing there are no spaces in the string argument - help!


if you do only 'onclick="do that"'
each time you click the radio you do that and no importance if it is secelcted
so ...

<input type=radio onclick="if(this.checked==true) alert('I am selected')
else alert('I am not selected');">
--
************************************************** ************
Stéphane MORIAUX : mailto:st*********************@wanadoo.fr
Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)
http://perso.wanadoo.fr/stephanePOINTmoriaux/internet/
************************************************** ************
Jul 20 '05 #6
Lee
@SM said:

Nige a ecrit :
In comp.lang.javascript, Nige wrote:
>>Is it possible to create an alert box when a radio button is selected? I
>>have a group of three, and I want a different alert for each one.
><input type="radio" name="sign" value="planningtosign" onClick=alert('ABC')>


I spoke too soon.

It works providing there are no spaces in the string argument - help!


if you do only 'onclick="do that"'
each time you click the radio you do that and no importance if it is secelcted
so ...

<input type=radio onclick="if(this.checked==true) alert('I am selected')
else alert('I am not selected');">


You're thinking of checkboxes. Whenever you click on a radio button,
it will be selected.

also, "if(this.checked==true)" can be shortened to "if(checked)".

Jul 20 '05 #7
"Lee" <RE**************@cox.net> wrote in message
news:br*********@drn.newsguy.com...
<snip>
also, "if(this.checked==true)" can be shortened to "if(checked)".


I don't think that I would recommend that shortcut. While it is the case
that many (and most modern) browsers provide a custom scope handling
mechanism for the event handling functions generated from event
attribute string by the browser and, although those mechanisms differ
considerably between browser implementations, that would result in the
identifier "checked" being resolved as a property of the checkbox, there
are browsers that do not provide any such scope handling mechanism.
Opera <= 6 being an example (though I would be surprised if there were
not others).

The internally generated event handling functions in Opera 6 resolve
scope exactly as if they were JavaScript defined function objects
assigned to the event properties of the corresponding DOM nodes. As a
result "checked", unqualified, is a reference to a (undefined?) global
variable. However, the - this - keyword is required by the language to
refer to the object to which the event handling function is attached
(and called) as a method.

My conclusion was that the best cross-browser support when writing even
handling attribute string would be achieved by behaving as if there was
no special scope handling mechanism associated with the resulting
function and write the same code as would be needed in a function
attached to the DOM node with JavaScript. So the object itself should be
accessed as - this -, the form as - this.form -, and so on.

Richard.
Jul 20 '05 #8

"Nige" <uY***@ntlworld.com> wrote in message
news:h3********************************@4ax.com...
In comp.lang.javascript, Nige wrote:
It works providing there are no spaces in the string argument


Thanks Vjekoslav, it needed quotes!
--
Nige

Please replace YYYY with the current year
ille quis mortem cum maximus ludos, vincat


You can have spaces in the string... just do it this way:

onClick="alert('AB CD EF')"

instead of the way you had originally posted...

onClick=alert('ABC')>
Jul 20 '05 #9

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

Similar topics

2
by: Bart Verbeke | last post by:
Hi, I have a form with 2 radio buttons (ACCEPT/REJECT). When the page is initially loaded, no textbox should be visible. When a user clicks the REJECT radio button, a textbox should...
3
by: jforena | last post by:
Hi, I am trying to create a javascript that will display a confirmation message when a user submits a form and has specifically selected a particular radio button. For example: <form...
3
by: ewitkop90 | last post by:
Here is my code: <SCRIPT> function transportchange(transport) { if (framenewinstall.Helpdesk.checked) framenewinstall.Helpdesk.checked=false; if (framenewinstall.CircuitNumber.checked)...
2
by: teddy.am | last post by:
Guys, I have a set of 6 radio buttons, infront of each one there's a textbox .... i need all textboxes disabled .... once one of the radio buttons is selected, the texbox infront of it will be...
4
by: tadisaus2 | last post by:
Hello, I am a newbie with Javascript. I have this question. I have created a form with 3 radio buttons, (male, female, other), whenever a user click on other, I like to have the text box enabled...
3
by: RogerInHawaii | last post by:
I want to effectively do a Post type submit to the very same page when the user clicks on a particular radio button. Of course, I also want it to recognize the click (i.e. checkmarking the radio...
10
by: mukeshrasm | last post by:
Hi I have a html in which there is two selection box and two radio button. Radio buttion is of array type. What I want if user will click the radio button then only he/she be able to make...
2
by: genkidave | last post by:
Hi there, I have three combo boxes that I would like to have Disabled (grayed out???) and preselected to a particular selection until a radio button (YES) is clicked, thus enabling the combo...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.