Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Posting a value for a field in select option

Reply
Thread Tools

Posting a value for a field in select option

 
 
J. Muenchbourg
Guest
Posts: n/a
 
      02-20-2004
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!
 
Reply With Quote
 
 
 
 
Bob Barrows
Guest
Posts: n/a
 
      02-21-2004
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"


 
Reply With Quote
 
 
 
 
Lance Wynn
Guest
Posts: n/a
 
      02-21-2004
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" <(E-Mail Removed)> wrote in message
news:uwfJXwA%(E-Mail Removed)...
> 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!



 
Reply With Quote
 
Bob Lehmann
Guest
Posts: n/a
 
      02-21-2004
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" <(E-Mail Removed)> wrote in message
news:uwfJXwA%(E-Mail Removed)...
> 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!



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript validation for a not required field, field is onlyrequired if another field has a value jr Javascript 3 07-08-2010 10:33 AM
Copy File Field Value to Dynamic File Field Value VUNETdotUS Javascript 25 11-10-2007 10:36 AM
Select box value changes value of hidden field dvwool@ix.netcom.com Javascript 6 04-27-2006 04:38 AM
How to know which option in select field was clicked last? smash2004@gmail.com Javascript 6 10-12-2005 02:03 PM
Selection from One SELECT changes selected option of another SELECT? J. Hall HTML 2 04-21-2004 05:36 PM



Advertisments