Re: Dynamically Name a Checkbox

Discussion in 'HTML' started by birdmant, Aug 19, 2004.

  1. birdmant

    birdmant Guest

    Jeff Thies wrote:
    > *birdmant wrote:
    > > I am running a query to return product codes and would like t

    > creata a
    > > checkbox for each row returned. I would like to give the checkbo

    > a
    > > name using this code so that I can identify it. I'm moving th

    > product
    > > code to an array but am not successful in setting the name to th

    > code
    > > value. I've tried arrays and variables to no avail.
    > >
    > > Is there a way to do this? This is the piece of code I'm using.
    > >
    > > while (!rs.EOF)
    > > {
    > > a[x] = rs.Fields("PROD_CD");
    > > Response.Write("<input type='checkbox' name=a[x] checked
    > > onclick='clickbox(this)'>");
    > > Response.Write("<br>");
    > > rs.MoveNext();
    > > x++;
    > > }

    >
    > I'm not ASP guy but doesn't that print a[x] instead of the value. .
    >
    > You'll want to quote the attribute if it contains spaces and mak
    > theres
    > characters it can't start with like digits (I think).
    >
    > I would do something like this:
    >
    > Response.Write("<input type='checkbox' name=checkbox_'" + a[x] + "'
    > checked onclick='clickbox(this)'>");
    >
    > Iterate through the form collection and look for fields startin
    > with
    > checkbox_ , and extract the field name.
    >
    > That may be bad ASP. I don't know how you guys can use ASP, what it
    > can't do drives me crazy!
    >
    > PROD_CD is unique isn't it?
    >
    > Jeff
    >
    > >
    > >
    > > Any help would be greatly appreciated.
    > >
    > > Tom
    > >
    > >
    > >
    > > --
    > > birdmant

    >
    > ------------------------------------------------------------------------
    > > Posted via http://www.forum4designers.com

    >
    > ------------------------------------------------------------------------
    > > View this thread

    > http://www.forum4designers.com/message109289.html
    > > *


    Jeff,

    Thanks for the reply. When I do this the name becomes:

    checkbox_ +a[x] +

    It doesn't put the value of array a[x] element.

    And yes, prod_cd is unique.

    To


    -
    birdman
    -----------------------------------------------------------------------
    Posted via http://www.forum4designers.co
    -----------------------------------------------------------------------
    View this thread: http://www.forum4designers.com/message109289.htm
     
    birdmant, Aug 19, 2004
    #1
    1. Advertising

  2. birdmant

    Jeff Thies Guest

    birdmant wrote:
    > Jeff Thies wrote:
    >
    >>*birdmant wrote:
    >>
    >>>I am running a query to return product codes and would like to

    >>
    >>creata a
    >>
    >>>checkbox for each row returned. I would like to give the checkbox

    >>
    >>a
    >>
    >>>name using this code so that I can identify it. I'm moving the

    >>
    >>product
    >>
    >>>code to an array but am not successful in setting the name to the

    >>
    >>code
    >>
    >>>value. I've tried arrays and variables to no avail.
    >>>
    >>>Is there a way to do this? This is the piece of code I'm using.
    >>>
    >>>while (!rs.EOF)
    >>>{
    >>>a[x] = rs.Fields("PROD_CD");
    >>>Response.Write("<input type='checkbox' name=a[x] checked
    >>>onclick='clickbox(this)'>");
    >>>Response.Write("<br>");
    >>>rs.MoveNext();
    >>>x++;
    >>>}

    >>
    >>I'm not ASP guy but doesn't that print a[x] instead of the value. .
    >>
    >>You'll want to quote the attribute if it contains spaces and make
    >>theres
    >>characters it can't start with like digits (I think).
    >>
    >>I would do something like this:
    >>
    >>Response.Write("<input type='checkbox' name=checkbox_'" + a[x] + "'
    >>checked onclick='clickbox(this)'>");
    >>
    >>Iterate through the form collection and look for fields starting
    >>with
    >>checkbox_ , and extract the field name.
    >>
    >>That may be bad ASP. I don't know how you guys can use ASP, what it
    >>can't do drives me crazy!
    >>
    >>PROD_CD is unique isn't it?
    >>
    >>Jeff
    >>
    >>
    >>>
    >>>Any help would be greatly appreciated.
    >>>
    >>>Tom
    >>>
    >>>
    >>>
    >>>--
    >>>birdmant
    >>>

    >>
    >>------------------------------------------------------------------------
    >>
    >>>Posted via http://www.forum4designers.com
    >>>

    >>
    >>------------------------------------------------------------------------
    >>
    >>>View this thread:

    >>
    >>http://www.forum4designers.com/message109289.html
    >>
    >>>*

    >
    >
    > Jeff,
    >
    > Thanks for the reply. When I do this the name becomes:
    >
    > checkbox_ +a[x] +


    Change my +'s to &'s. Didn't I mention I'm not an ASP guy?

    This is basic ASP stuff. Take a look at an ASP FAQ like:

    <URL: http://www.aspfaqs.com/aspfaqs/ >

    Also, stop using the Designers Forum. Find out how to set up usenet on
    your mail client. Microsoft has a free usenet server:
    news.microsoft.com. Set that up and ask in a MS ASP group. And then read
    the posting guidelines or read other posts to see how this is done.

    Usenet is a wonderfull thing and is much better when you access it
    correctly! You'll be telling/showing others this in a few months.

    Jeff


    >
    > It doesn't put the value of array a[x] element.
    >
    > And yes, prod_cd is unique.
    >
    > Tom
    >
    >
    >
    > --
    > birdmant
    > ------------------------------------------------------------------------
    > Posted via http://www.forum4designers.com
    > ------------------------------------------------------------------------
    > View this thread: http://www.forum4designers.com/message109289.html
    >
     
    Jeff Thies, Aug 21, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TWljaGHFgiBKYW51c3pjenlr?=

    Getting dynamically web app name [or virtual dir name]

    =?Utf-8?B?TWljaGHFgiBKYW51c3pjenlr?=, Aug 30, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    765
    Craig Deelsnyder
    Aug 30, 2004
  2. tshad
    Replies:
    0
    Views:
    552
    tshad
    Apr 15, 2005
  3. Vikram

    disable checkbox list checkbox

    Vikram, Jan 25, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,414
    ThunderMusic
    Jan 25, 2006
  4. birdmant

    Dynamically Name a Checkbox

    birdmant, Aug 18, 2004, in forum: HTML
    Replies:
    1
    Views:
    394
    Jeff Thies
    Aug 18, 2004
  5. PhpCool
    Replies:
    9
    Views:
    252
    David Mark
    Oct 30, 2008
Loading...

Share This Page