Posting a value for a field in select option

J

J. Muenchbourg

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
 
B

Bob Barrows

J. Muenchbourg said:
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
 
L

Lance Wynn

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
 
B

Bob Lehmann

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top