473,767 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Posting a value for a field in select option

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="CategoryN ame">
<option selected></option>
<option value="first">f irst category</option>
<option value="second"> second category</option>
</select>
<br>
New Category<br>
<input name="CategoryN ame" 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
3 2147
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="CategoryN ame">
<option selected></option>
<option value="first">f irst category</option>
<option value="second"> second category</option>
</select>
<br>
New Category<br>
<input name="CategoryN ame" 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
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("Catego ryName")(1) 'would be the select option
request("Catego ryName")(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******** ********@TK2MSF TNGP10.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="CategoryN ame">
<option selected></option>
<option value="first">f irst category</option>
<option value="second"> second category</option>
</select>
<br>
New Category<br>
<input name="CategoryN ame" 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
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******** ********@TK2MSF TNGP10.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="CategoryN ame">
<option selected></option>
<option value="first">f irst category</option>
<option value="second"> second category</option>
</select>
<br>
New Category<br>
<input name="CategoryN ame" 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2233
by: Vic Spainhower | last post by:
Hello, I am new to php and mySQL so this is probably something very basic that I'm missing. Basically, on the page I have 2 combo boxes but 1 of them is not getting the value passed when the page is reloaded so the database can be updated. I am echoing the field names passed and the field "theDriver" is there but it's empty. I've include the code parts where I believe the problem should be but I'm stumped and I've been trying to solve...
1
14156
by: G Kannan | last post by:
Hey all! I have written a perl script to retrieve information from a HTML Form and insert the data into an Oracle database table. I am gettting the the following error message: "Use of uninitialized value in concatenation (.) at register.pl line 38, <STDIN> line 10." The PERL code is as follows:
3
16183
by: Sarah West | last post by:
Hi, I have the following problem; This is my form, i would like to default the select box to USA, and default the text field to a name such as 'Sarah' and the hidden field to another number like '876543', when the user clicks on the check box, otherwise the fields should be blank, the value of the select box dosnt matter much, only that it defaults to USA, when the user checks it. Can anyone help? i have tried a google with no luck,...
16
11501
by: cwizard | last post by:
I'm calling on a function from within this form, and there are values set but every time it gets called I get slammed with a run time error... document.frmKitAmount.txtTotalKitValue is null or not an object... the function is like so: function calc_total() { var x,i,base,margin,total,newmargin,newtotal; base = document.frmKitAmount.txtTotalKitValue.value; margin = document.frmKitAmount.margin.value/100;
5
1885
by: cmc_dermo | last post by:
I have a form that has a select list. A user chooses a value and the page refreshes showing the selected value in the dropdown box. So I want to use Javascript to get the selected query from the form. I then want to pass it as a hidden field. So for example the section of the page I'm interested in will look like
3
1468
by: Noah | last post by:
Hello. I have a form like so: <FORM NAME="form1" METHOD = "post"> <SELECT NAME="select"> <OPTION VALUE = "1">Option 1</OPTION> <OPTION VALUE = "2">Option 2</OPTION>
1
1951
by: hotrod57 | last post by:
I am trying to append the results from a form to a text file. My code is supposed to print out the results on one page, and append the results to another page each time data is entered on the form and the submit button is hit. Unfortunately, it is only printing out the message acknowledging the submit button--no data on either form. Here is the code below, please help if you can. PHP code that reads the form submission: <?php function...
17
2773
vikas251074
by: vikas251074 | last post by:
I have create form as below - <table> <tr> <td align="right">VLAN Name : </td> <td> <select name="vlan_name" style="width:150px "> <% set rs = conn.execute("select vlan_name from vlan_master order by vlan_name") do while not rs.eof%> <option value="<%=rs("vlan_name")%>"><%=rs("vlan_name")%></option>
10
7421
by: dkyadav80 | last post by:
<html> /// here what shoud be java script for: ->when script run then not display all input text field only display selection field. ->when user select other value for institute only this field display not display degree text field ->when user select other value in the selection field for degree then text field display and wise versa //// <bodly> <table>
0
9404
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10009
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7381
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6651
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3929
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.