473,578 Members | 2,818 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

retrieving the choise of a combo box

Hi,

On a webpage I have three comboboxes. The second and the third are
dynamically filled dependent from the choice in the first combobox.
Each choice in all three boxes consist of a numeric value and a
string. This is done through a javascript and it uses the numeric
values of the first box. When submitting the page to an asp script I
don't want to post these numeric values but the selected strings. Can
this be done???

Regards, Klaas Seelen
Jul 22 '05 #1
5 2703
Klaas Seelen wrote:
Hi,

On a webpage I have three comboboxes. The second and the third are
dynamically filled dependent from the choice in the first combobox.
Each choice in all three boxes consist of a numeric value and a
string. This is done through a javascript and it uses the numeric
values of the first box. When submitting the page to an asp script I
don't want to post these numeric values but the selected strings. Can
this be done???

You will only be able to see the values in the submitted data. So force the
value property or the options to contain the strings you want to post
instead of the numeric values. There is no requirement that the value
property has to be something different from the text property of the option.

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 22 '05 #2
Klaas Seelen wrote:
On a webpage I have three comboboxes. The second and the third are
dynamically filled dependent from the choice in the first combobox.
Each choice in all three boxes consist of a numeric value and a
string. This is done through a javascript and it uses the numeric
values of the first box. When submitting the page to an asp script I
don't want to post these numeric values but the selected strings. Can
this be done???


Let me first state that I would be inclined to get rid of the numbers
altogether. If you are not interested in them at submission, why bother
putting them into the document in the first place?

Back to your question. There are several ways to do this. Perhaps the most
straightforward is to change the value at submit:

option.value = option.text // [1],[2]

If your SELECT elements (they are not "comboboxes ") are of the "select-one"
type [3], then it suffices to do it this way:

sel[sel.selectedInd ex].value = sel[sel.selectedInd ex].text

For "select-multiple" elements, you should iterate through the entire set of
option elements.

Please bear in mind that "option" and "sel" are object references,
representing something like
document.forms["myForm"].elements["mySelectElemen t"][i] and
document.forms["myForm"].elements["mySelectElemen t"], respectively.
[1]
http://msdn.microsoft.com/workshop/a...es/value_3.asp
[2]
http://msdn.microsoft.com/workshop/a...ies/text_3.asp
[3]
http://msdn.microsoft.com/workshop/a...ies/type_9.asp
--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 22 '05 #3
I have thought of that one too, the problem is I need the numeric values for
my javascript to dynamically fill te second and third box so I hope ther is
an other solution...

Klaas Seelen

"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> schreef in bericht
news:eP******** ******@TK2MSFTN GP15.phx.gbl...
Klaas Seelen wrote:
Hi,

On a webpage I have three comboboxes. The second and the third are
dynamically filled dependent from the choice in the first combobox.
Each choice in all three boxes consist of a numeric value and a
string. This is done through a javascript and it uses the numeric
values of the first box. When submitting the page to an asp script I
don't want to post these numeric values but the selected strings. Can
this be done???

You will only be able to see the values in the submitted data. So force
the value property or the options to contain the strings you want to post
instead of the numeric values. There is no requirement that the value
property has to be something different from the text property of the
option.

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 22 '05 #4
You have two choices:

Use client-side code (as suggested by Dave) to either either of these
actions on submit:
a. modify the selected option elements
b. populate hidden textboxes with the values of the selects
Use server-side code to retrieve the strings that correspond to the numeric
values from whatever source is used to provide the data for the "combos"
(note: there is no such thing as a "combo" in html - you have select
elements). Provide a little more info and we may be able to help you with
this.

Klaas Seelen wrote:
I have thought of that one too, the problem is I need the numeric
values for my javascript to dynamically fill te second and third box
so I hope ther is an other solution...

Klaas Seelen


--
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 22 '05 #5
Thanks a lot, it worked...

Klaas Seelen

"Dave Anderson" <GT**********@s pammotel.com> schreef in bericht
news:ud******** ********@tk2msf tngp13.phx.gbl. ..
Klaas Seelen wrote:
On a webpage I have three comboboxes. The second and the third are
dynamically filled dependent from the choice in the first combobox.
Each choice in all three boxes consist of a numeric value and a
string. This is done through a javascript and it uses the numeric
values of the first box. When submitting the page to an asp script I
don't want to post these numeric values but the selected strings. Can
this be done???


Let me first state that I would be inclined to get rid of the numbers
altogether. If you are not interested in them at submission, why bother
putting them into the document in the first place?

Back to your question. There are several ways to do this. Perhaps the most
straightforward is to change the value at submit:

option.value = option.text // [1],[2]

If your SELECT elements (they are not "comboboxes ") are of the
"select-one" type [3], then it suffices to do it this way:

sel[sel.selectedInd ex].value = sel[sel.selectedInd ex].text

For "select-multiple" elements, you should iterate through the entire set
of option elements.

Please bear in mind that "option" and "sel" are object references,
representing something like
document.forms["myForm"].elements["mySelectElemen t"][i] and
document.forms["myForm"].elements["mySelectElemen t"], respectively.
[1]
http://msdn.microsoft.com/workshop/a...es/value_3.asp
[2]
http://msdn.microsoft.com/workshop/a...ies/text_3.asp
[3]
http://msdn.microsoft.com/workshop/a...ies/type_9.asp
--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message.
Use of this email address implies consent to these terms. Please do not
contact me directly or ask me to contact you directly for assistance. If
your question is worth asking, it's worth posting.

Jul 22 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1350
by: Mark | last post by:
Hi Bit of an unusual one. I have an Access front end. Two tables tblHeader and tblDetails. Each has an ID field (unique and primary) plus other fields as necessary. On aform is 3 fields from the header: 1. A text field 2. A SupplierID field (combo dropdown) 3. A SupplierBranchID field (combo dropdown)
10
1689
by: Krakatioison | last post by:
Hi everyone, can someone point me to download of an example for saving and retrieving to/from MYSQL database. Or did anyone of you tried this and could share your code with me. I've got some data which needs to be put to mysql database using VB.NET and I can't figure this out. Thanks a lot. K.
5
6615
by: Edward Clements | last post by:
I have an enum defined as public enum velocityUom { /// <remarks/> ms, /// <remarks/> cma, ...
0
1589
by: Edward Clements | last post by:
This post is a followup to the thread "retrieving the XmlEnumAttribute values for an Enum" in this same forum earlier this month, since my last query in that thread went unanswered. I have an enum defined (DotNet v2) as public enum velocityUom { ms = 21,
10
2753
by: shanmukhi | last post by:
hi all in jsp i created a combo box and i written a java script to select values from combo box. when i select a value from combo box it should go to the another jsp page for that i passed the selected value as a string along with the url in java script. like <a href=..........?<%=val%> then how can i get this value into another jsp...
2
6214
by: radziowi | last post by:
Hello! I have got problem with date in SQL query. I would like choise date bettwen 2 dates for example SQL query select * from news WHERE data BETWEEN 24-07-2007 AND 06-08-2007 In SQL working but when i use Cold Fusion my query is still wrong <cfset today = Now()> <cfoutput>#DateFormat(today, "dd-mmm-yyyy")#</cfoutput> <cfquery name="News"...
0
1159
by: sanalsuryakalady | last post by:
Hello All, I have 2 combo box in ASP.NET 1.1. When ever I change the value in one combo the other combo will be loaded with the new values using XMLHTTP.But when I post back the screen I lose the newly added values in Combo and the first values when the page loaded will appear in the code behind. If any body knows a solution to this pls let me...
9
9909
by: ajos | last post by:
Hello friends, After thinking about this for sometime, i decided to post this in the java forum. Well my problem here in detail is, i have 3 jsp pages where in a.jsp(for example) i have a combo box, based on the selection of the value in that combo box, b.jsp page gets populated with the value associated to a.jsp, and again based on the...
4
6067
by: Luqman | last post by:
I am using Visual studio 2008 and ASP.Net 3.5 How can I fill a combo with List of Local Printers, installed on Client Machine ? If I have to buy any Activex Control from Internet, please do recommend. Best Regards, Luqman
0
7850
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8126
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8150
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6524
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5664
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...
0
3786
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3801
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1391
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1114
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...

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.