By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,246 Members | 1,451 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,246 IT Pros & Developers. It's quick & easy.

Posting a value for a field in select option

P: n/a
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!
Jul 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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"
Jul 19 '05 #2

P: n/a
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" <an*******@dex.com> wrote in message
news:uw****************@TK2MSFTNGP10.phx.gbl...
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!

Jul 19 '05 #3

P: n/a
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" <an*******@dex.com> wrote in message
news:uw****************@TK2MSFTNGP10.phx.gbl...
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!

Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.