Posting a value for a field in select option

Discussion in 'ASP General' started by J. Muenchbourg, Feb 20, 2004.

  1. I have an ASP admin script where I'm adding records, and I have a
    category that already has set name values hard-coded into a selct option
    pulldown, but if the user wants to create a new category and not use the
    select pulldown, the value will end up being " , newvalue" when posting
    from this sequence of pulldown and input text box:

    <select name="CategoryName">
    <option selected></option>
    <option value="first">first category</option>
    <option value="second">second category</option>
    </select>
    <br>
    New Category<br>
    <input name="CategoryName" type="text" size="26"
    maxlength="255">

    What is the best way of not having that extra preceeding comma appear as
    the value if the user chooses to add a brand new category?

    thx
    Muench

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    J. Muenchbourg, Feb 20, 2004
    #1
    1. Advertising

  2. J. Muenchbourg

    Bob Barrows Guest

    J. Muenchbourg wrote:
    > I have an ASP admin script where I'm adding records, and I have a
    > category that already has set name values hard-coded into a selct
    > option pulldown, but if the user wants to create a new category and
    > not use the select pulldown, the value will end up being " ,
    > newvalue" when posting from this sequence of pulldown and input text
    > box:
    >
    > <select name="CategoryName">
    > <option selected></option>
    > <option value="first">first category</option>
    > <option value="second">second category</option>
    > </select>
    > <br>
    > New Category<br>
    > <input name="CategoryName" type="text" size="26"
    > maxlength="255">
    >
    > What is the best way of not having that extra preceeding comma appear
    > as the value if the user chooses to add a brand new category?
    >


    Ummmm - don't put it there?

    You're in control of the sql statement, not the data. You can choose whether
    or not a comma should appear in the statement or not. It sounds as if you
    need a simple If statement in your code that builds the sql statement.

    Bob Barrows


    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows, Feb 21, 2004
    #2
    1. Advertising

  3. J. Muenchbourg

    Lance Wynn Guest

    You could name the New Category Field something different,

    or, when you have more than one element with the same name, you can address
    them like you would an array
    request("CategoryName")(1) 'would be the select option
    request("CategoryName")(2) 'would be the textbox

    then just put a little logic in there to decide when to use either one

    Lance


    "J. Muenchbourg" <> wrote in message
    news:uwfJXwA%...
    > I have an ASP admin script where I'm adding records, and I have a
    > category that already has set name values hard-coded into a selct option
    > pulldown, but if the user wants to create a new category and not use the
    > select pulldown, the value will end up being " , newvalue" when posting
    > from this sequence of pulldown and input text box:
    >
    > <select name="CategoryName">
    > <option selected></option>
    > <option value="first">first category</option>
    > <option value="second">second category</option>
    > </select>
    > <br>
    > New Category<br>
    > <input name="CategoryName" type="text" size="26"
    > maxlength="255">
    >
    > What is the best way of not having that extra preceeding comma appear as
    > the value if the user chooses to add a brand new category?
    >
    > thx
    > Muench
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Lance Wynn, Feb 21, 2004
    #3
  4. J. Muenchbourg

    Bob Lehmann Guest

    The problem is that you have your text field named the same as your select
    list so you are getting a comma delimited list of the values posted.

    Name the textbox something else.

    Bob Lehmann

    "J. Muenchbourg" <> wrote in message
    news:uwfJXwA%...
    > I have an ASP admin script where I'm adding records, and I have a
    > category that already has set name values hard-coded into a selct option
    > pulldown, but if the user wants to create a new category and not use the
    > select pulldown, the value will end up being " , newvalue" when posting
    > from this sequence of pulldown and input text box:
    >
    > <select name="CategoryName">
    > <option selected></option>
    > <option value="first">first category</option>
    > <option value="second">second category</option>
    > </select>
    > <br>
    > New Category<br>
    > <input name="CategoryName" type="text" size="26"
    > maxlength="255">
    >
    > What is the best way of not having that extra preceeding comma appear as
    > the value if the user chooses to add a brand new category?
    >
    > thx
    > Muench
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Bob Lehmann, Feb 21, 2004
    #4
    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. J. Hall
    Replies:
    2
    Views:
    1,090
    Jeff Thies
    Apr 21, 2004
  2. Replies:
    6
    Views:
    126
  3. WebRaster
    Replies:
    1
    Views:
    280
    Francisco Spaeth
    Oct 26, 2005
  4. Nick Spacek

    Removing select option removes entire select

    Nick Spacek, Jun 21, 2006, in forum: Javascript
    Replies:
    1
    Views:
    154
    Matt Kruse
    Jun 21, 2006
  5. jr
    Replies:
    3
    Views:
    448
Loading...

Share This Page