[Javascript] problem of only one radio button

Abraham Liu liuabe99 at hotmail.com
Fri Jul 20 12:53:09 CDT 2001


Hi Rodney Myers,
According to JavaScript - The definitive Guide 3rd Edition page 439, 
checkbox does have "length" if you have a group checkboxes.  Otherwise, you 
can pull the value out directly by using placeOrder.sel.value, in my case.
But your suggestion makes my program working and I learned something too.
Thank you for the valuable suggestion.
Abe Liu


>From: Rodney Myers <rodney at aflyingstart.net>
>Reply-To: javascript at LaTech.edu
>To: javascript at LaTech.edu
>Subject: Re: [Javascript] problem of only one radio button
>Date: Fri, 20 Jul 2001 17:18:58 +0100
>
>checkbox is not array and has no length
>radio buttons with same name form part of an array.
>R
>
>Abraham Liu wrote:
>
> > Hi Rodney Myers,
> > Thank your answer. I did what you said. But when I check the length of 
>the
> > checkbox. It still show undefined instead of 1. Why?
> > Can you help me again?
> > Thanks.
> > Abe Liu
> >
> > I have the codes as following,
> >
> > .
> > .
> > function display_checkQty() {
> >      var tot = 0;
> >      var val = 0;
> >
> >      alert("sel-length= "+placeOrder.sel.length);
> >      .
> >      .
> > }
> >
> > .
> > .
> > if (rsa.length == 1) {
> > %>
> >                       <td align="center" bordercolor="#FFFFFF" 
>width="44"
> > height="15" <%= bgc %>><input type="checkbox" name="sel"
> > value="<%=tknAndUnits%>" onClick="display_checkQty()"></td>
> > <%
> >    } else {
> > %>
> >                       <td align="center" bordercolor="#FFFFFF" 
>width="44"
> > height="15" <%= bgc %>><input type="radio" name="sel"
> > value="<%=tknAndUnits%>" onClick="display_radioQty()"></td>
> > <%
> >    }
> >
> > >From: Rodney Myers <rodney at aflyingstart.net>
> > >Reply-To: javascript at LaTech.edu
> > >To: javascript at LaTech.edu
> > >Subject: Re: [Javascript] problem of only one radio button
> > >Date: Fri, 20 Jul 2001 15:01:45 +0100
> > >
> > > > Is it true that radio button will function correctly only at least 
>two
> > >of them
> > >exist in form ?
> > >YES
> > >
> > > > Is it true that checkbox will function correctly only at least two 
>of
> > >them
> > >exist in form ?
> > >NO, One checkbox is OK
> > >
> > >I advise that server side you make a count of the rows found.
> > >If only one you write a checkbox, and appropriate script
> > >If 2 or more write radio buttons.
> > >
> > >The radio buttons array length returns an error if there is only one 
>RB.
> > >
> > >hth
> > >
> > >Rodney
> > >
> > >
> > >Abraham Liu wrote:
> > >
> > > > Hi,
> > > > In my jsp program, I select a number of rows from database table, 
>then
> > > > display them in form table. Each row attachs a radio button, So 
>users
> > >can
> > > > select one of rows and do further process.
> > > > The reason I use radio button is that I concatenate 3 table columns 
>and
> > > > store them in "value" property of button. When user click button, I 
>use
> > > > javascript "split" function to get these 3 columns back. Everything
> > >seemed
> > > > working just fine. But I realized that if only one row got selected
> > >which
> > > > meaned only one button exists also, then the fuction of radio button
> > >didn't
> > > > worked and "split" won't work either. I switched to checkbox, I got 
>the
> > >same
> > > > result.
> > > >
> > > > Is it true that radio button and checkbox will function correctly 
>only
> > >at
> > > > least two of them exist in form ?
> > > > In my case, the number of radio button are genarated dynamically
> > >depending
> > > > on the number rows being selected. So what can I do ? Do I have some
> > >other
> > > > alternative ways ?
> > > > I will be appreciated some kindly help.
> > > > Thank you.
> > > > Abe Liu
> > > >
> > > > _________________________________________________________________
> > > > Get your FREE download of MSN Explorer at
> > >http://explorer.msn.com/intl.asp
> > > >
> > > > _______________________________________________
> > > > Javascript mailing list
> > > > Javascript at LaTech.edu
> > > > http://www.LaTech.edu/mailman/listinfo/javascript
> > >
> > >--
> > >Shop at ssistant Add-ons and Developer Workshops
> > >http://www.aflyingstart.net/addons/
> > >
> > >Enquiries regarding Shop at ssistant Classic training :
> > >Call 01256 880770
> > >
> > >Rodney Myers
> > >Based in Oxford, England
> > >Technical Director, Shop at ssistant eCommerce Solutions
> > >
> > >
> > >_______________________________________________
> > >Javascript mailing list
> > >Javascript at LaTech.edu
> > >http://www.LaTech.edu/mailman/listinfo/javascript
> >
> > _________________________________________________________________
> > Get your FREE download of MSN Explorer at 
>http://explorer.msn.com/intl.asp
> >
> > _______________________________________________
> > Javascript mailing list
> > Javascript at LaTech.edu
> > http://www.LaTech.edu/mailman/listinfo/javascript
>
>--
>Shop at ssistant Add-ons and Developer Workshops
>http://www.aflyingstart.net/addons/
>
>Enquiries regarding Shop at ssistant Classic training :
>Call 01256 880770
>
>Rodney Myers
>Based in Oxford, England
>Technical Director, Shop at ssistant eCommerce Solutions
>
>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>http://www.LaTech.edu/mailman/listinfo/javascript


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp




More information about the Javascript mailing list