Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #31354

Re: Intercept radio onclick event

From wmgill <webworker1950@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: Intercept radio onclick event
Date 2016-09-13 09:17 -0400
Organization A noiseless patient Spider
Message-ID <nr8u8i$6na$1@dont-email.me> (permalink)
References <nr6ja2$dqc$1@dont-email.me>

Show all headers | View raw


On 9/12/2016 11:58 AM, wmgill wrote:
> Is there a way to intercept a radio button onclick event and pass it
> through a confirmation process before allowing it to proceed or
> cancelling it?  I have found several solutions that propose to do this,
> but in fact they just set or reset the radio's checked property, which
> doesn't reset any other radio button in the group to original state.
>
> The reason I ask is I have a data input form, and am using radio buttons
> to select which mode (add new, edit existing, or delete existing
> record).  If a user begins in one mode then wants to switch to another I
> need to test that no data will be lost in the process (i.e. changing
> mode without deciding what to do with the data in the partially filled
> form).
>
> Radio buttons may not be the best approach. I can think of several other
> ways to accomplish this, but welcome any insight.

I think I may have found some of my problem(s).  Due to poor memory, and 
inconsistent browser response I was getting unexpected, and inconsistent 
results, causing me to draw wrong conclusions.

I seem to be catching the onclick event, but not early enough in the 
process. So I still need some help in a couple areas.

I found that:

<input type="radio" name="test" value="3" onclick="return false;"> 
works correctly on all the browsers I tested except MSIE.

<input type="radio" name="test" value="2" onclick="catchclick(this);"> 
where catchclick() returns the result of confirm(), does not work on any 
browser tested.

and finally <input type="radio" name="test" value="4" onclick="return 
catchclick(this);"> works but seems to be capturing the event later in 
the process.  While onclick="return false;" never toggles the radio 
buttons, onclick="return catchclick(this);" toggles them, but then 
differs in different browsers.  In MS browsers (IE and Edge) a returned 
false deselects the radio but does not reselect the previous radio. In 
Firefox and Chrome a returned false deselects the clicked radio and 
reselecs the previous radio.

Any insights as to what is going on, and how to correct it?

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Intercept radio onclick event wmgill <webworker1950@gmail.com> - 2016-09-12 11:58 -0400
  Re: Intercept radio onclick event wmgill <webworker1950@gmail.com> - 2016-09-13 09:17 -0400
    Re: Intercept radio onclick event "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-09-13 15:35 +0200
      Re: Intercept radio onclick event wmgill <webworker1950@gmail.com> - 2016-09-13 10:27 -0400
      Re: Intercept radio onclick event Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-09-13 16:58 +0200
  Intercept radio onclick event Ram Tobolski <ramtob@gmail.com> - 2016-09-13 11:38 -0700
    Re: Intercept radio onclick event wmgill <webworker1950@gmail.com> - 2016-09-13 15:53 -0400

csiph-web