RE: addEventListener to radio button
Jacob Kjome <[email protected]>
| Newsgroups | gmane.comp.java.enhydra.barracuda.general |
|---|---|
| Message-ID | <[email protected]> |
I never got any comments on my proposal below. Is that because everyone thinks it is perfect and I should just go ahead and implement it this way or is everyone just a bit busy at the moment? I guess I'll assume the latter. If so, if some of you could please take the time to evaluate my proposal and come up with concerns, counter-proposals, etc..., that would be good so we can get this fixed soon....and maybe actually have a release sometime in the near future. Jake At 07:17 PM 3/31/2003 -0600, you wrote: >Nope, doing this.readOnly=true won't work. It only works for text fields >and textareas based on my testing in Mozilla. And in IE, the behavior >isn't exactly what one might like it to be. For instance... > ><input type="text" name="thetext" value="blah" >onclick="this.readOnly=true;" /> > >In Mozilla, if you click in the text box, you will see the cursor for >about 1 millisecond (or so) and you can get few letters in if you type >quickly right as your are clicking in the element. In IE, you can click >in there and then type all you want. Only after you take cursor focus out >of the element will it actually act as a "readonly" element. You will >find you can no longer type there now. > >So, this.readOnly=true is not only buggy but doesn't serve the purpose on >most elements. > >I've written up a demo that shows basically what I propose. You can see >it here... >http://www.visi.com/~hoju/mozilla/formvaluetest.html > >It allows for form submittal all from the same code and will catch a form >submitted from the Enter key as well. Note that this also allows for nice >fallback for browsers with javascript disabled...with the caveat that you >will have had to set the form "action" attribute already since >this.form.action='someEvent.event', obviously, won't work. > >If you do a view-source on the formvaluetest.html page, take a look at the >javascript functions "doSubmit()" and "lockAndSubmit()". Then look at the >way the form is set up... > ><form name="testform" id="testform" action="formvaluetest.html" >method="get" onsubmit="return lockAndSubmit(this);"> > >Then look at any place that specifically attempts to submit the form via >javascript... > ><input type="radio" readonly="readonly" name="testradio" id="South Park" >value="South Park" >onclick="this.form.action='formvaluetest.html';lockAndSubmit(this.form);" /> > ><a href="#" onclick="return >lockAndSubmit(document.forms['testform']);">javascript submit</a> > > >All code calls the "lockAndSubmit()" function (it could also just call the >"doSubmit()" function if the form element disabling isn't required). > > >We could add those two methods (with more unique names) and include them >via an xlib reference and then instead of writing this.disabled=true" on >everything, just call "lockAndSubmit(this.form)". > >Also, notice that we don't have to do >document.someForm.action='someEvent.event'. Instead, we can just do >this.form.action='someEvent.event'. There is no functional difference, >but it takes less logic to do this since in the former case we have to get >the name of the current form element's form. We can cut that logic out >entirely since we already know that javascript knows how to get that >reference from the form element itself. > > >Oh, and you can play with disabling submission of the form by commenting >out the following line in "doSubmit()"... >objForm.submit(); > >That will cause "false" to be returned which will disabled the form >submission. > >Let me know what you think. > >Jake > >At 06:30 PM 3/31/2003 -0500, you wrote: >>Yeah, the reason for disabling is so that people don't press submit twice. >>There are a couple of options here: we could make it NOT disble in the case >>of radiobuttons, OR, we could do the readonly thing if that would work >>better. >> >>Ideas? >> >>Christian >>---------------------------------------------- >>Christian Cryder [[email protected]] >>Internet Architect, ATMReports.com >>Barracuda - http://barracudamvc.org >>---------------------------------------------- >>"Coffee? I could quit anytime, just not today" >> >> > -----Original Message----- >> > From: [email protected] >> > [mailto:[email protected]]On Behalf Of Shawn Wilson >> > Sent: Monday, March 31, 2003 6:31 PM >> > To: [email protected] >> > Subject: Re: [Barracuda] addEventListener to radio button >> > >> > >> > Hey Jake, >> > >> > What is the reasoning for disabling the element (other than submit >> > buttons that may accidently get clicked more than once) anyways? Would >> > setting readonly instead still produce the desired behavior? >> > >> > -shawn >> > >> > Jacob Kjome wrote: >> > > >> > > You know what, that won't work (at least not reliably) on radio >> > > buttons. Here's the problem... >> > > >> > > Setting disabled=true makes it so that the browser won't send the data >> > > for that form element (at least in recent browsers such as Mozilla). >> > > Setting this.disabled=true on buttons works because they don't contain >> > > data needed for processing on the server. However, when you do >> > this for >> > > elements that, themselves, contain data that are needed to be processed >> > > on the server, you shoot yourself in the foot because the data never >> > > gets sent for that disabled form element. >> > > >> > > The only thing that is curious is that you even get data at all >> > for this >> > > form element because it shoudn't be sent at all. What browser are you >> > > using? >> > > >> > > This means that we need to come up with another way selectively >> > > disabling form elements so that we don't disabled elements that >> > actually >> > > contain data to send to the server. >> > > >> > > Jake >> > > >> > > At 11:11 AM 3/31/2003 -0500, you wrote: >> > > >> > >>Here is the generated >> > >>code for the radio button >> > >>input: >> > >> >> > >> >> > >> >> > >> >> > >> >> > >><input checked="checked" id="SpaceByRoadway" >> > >>name="SpaceBy" onclick="this.disabled=true; >> > >>document.EditForm.action='ActionEvent.event?$eid=TSSDownloadScre >> > en$GetTSSDownloadHandler';document.EditForm.submit(); >> > >>return false;" type="radio" >> > >>value="roadway">Roadway >> > >> >> > >> >> > >> >> > >><input id="SpaceByCorridor" name="SpaceBy" >> > >>onclick="this.disabled=true; >> > >>document.EditForm.action='ActionEvent.event?$eid=TSSDownloadScre >> > en$GetTSSDownloadHandler';document.EditForm.submit(); >> > >>return false;" type="radio" >> > >>value="corridor">Corridor >> > >> >> > >> >> > >> >> > >><input id="SpaceByStation" name="SpaceBy" >> > >>onclick="this.disabled=true; >> > >>document.EditForm.action='ActionEvent.event?$eid=TSSDownloadScre >> > en$GetTSSDownloadHandler';document.EditForm.submit(); >> > >>return false;" type="radio" >> > >>value="station">Station >> > >> >> > >> >> > >> >> > >> >> > >>Im not sure exactly which version of barracuda Im using, but >> > >>the timestamp on the class files in the JAR is >> > >>2/21/2003. >> > >> >> > >> >> > >> >> > >> >> > >> David R Robison >> > >> >> > >> Open Roads Consulting, Inc. >> > >> >> > >> http://www.openroadsconsulting.com >> > >> >> > >> >> > >> >> > >> -----Original Message----- >> > >> *From:* [email protected] >> > >> [mailto:[email protected]] *On Behalf Of *Jacob Kjome >> > >> *Sent:* Friday, March 28, 2003 4:24 PM >> > >> *To:* [email protected] >> > >> *Subject:* Re: [Barracuda] addEventListener to radio button >> > >> >> > >> >> > >> >> > >> >> > >> Hi David, >> > >> >> > >> I think this is a problem with the way Barracuda currently does form >> > >> submittal via javascript. Just like you said, the form gets submitted >> > >> before the value is changed. Normally you wouldn't run into this >> > >> because you'd set you form components to their appropriate values and >> > >> then click a "submit" button which would have the listener attached to >> > >> it. Hmm.... >> > >> >> > >> Can you send a snippet of the generated html for this page just for >> > >> reference? Then we can think about what might be done to solve this >> > >> issue. >> > >> >> > >> Oh, and what version of Barracuda are you using? A release or the >> > >> latest CVS? >> > >> >> > >> Jake >> > >> >> > >> At 03:54 PM 3/28/2003 -0500, you wrote: >> > >> >> > >> I have 3 <INPUT> elements all of type "radio" and with the same >> > >> "name". I want >> > >> to catch an event whenever a new selection is made. The values of the >> > >> input >> > >> fields are "one", "two", "three". I start with the <INPUT> "one" >> > >> selected. When >> > >> I click on "two" or "three" the event gets directed to my event >> > >> listener but the >> > >> value of the "radio" is still "one". No matter what I click, the value >> > >> is always >> > >> returned as "one". It seems that the event is firing when a radio >> > >> button is >> > >> clicked but before the selected value has been changed. Any ideas on >> > >> what may be >> > >> happening or how to work around it? >> > >> >> > >> Thanks, >> > >> David Robison >> > >> _______________________________________________ >> > >> Barracuda mailing list >> > >> [email protected] >> > >> http://barracudamvc.org/lists/listinfo/barracuda >> > >> > _______________________________________________ >> > Barracuda mailing list >> > [email protected] >> > http://barracudamvc.org/lists/listinfo/barracuda >> >>_______________________________________________ >>Barracuda mailing list >>[email protected] >>http://barracudamvc.org/lists/listinfo/barracuda