Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-24-2002, 07:41 PM   PM User | #1
RadarBob
Regular Coder

 
Join Date: Jun 2002
Location: Round Rock, Texas
Posts: 443
Thanks: 0
Thanked 0 Times in 0 Posts
RadarBob is an unknown quantity at this point
Question how to: Store all <option>s of a <select> object

I have a <select> object with N <option>s. I want to store the entire list to the (MS SQL) database. The stored procedure will take care of database integrity issues. The exact syntax and what "request.form" objects/properties/methods/etc. that are available eludes me.

I know what I want to do: upon SUBMIT, create a new recordset, put ALL the values from the <select> in it then run an SQL stored procedure (no prob' here) to stuff them into the DB.

I understand the response object receives only those radio button & checkbox values that are "selected" - NOT the complete radio button (checkbox) set ... - I assume this is also true of <select>. If so, easy enough to set the "selected" property in script just prior to SUBMIT.

How do I tell how many <options> I have so I can run a loop? In other words, are the same HTML form object properties & methods availble after the form is passed to the server?

I think I don't want to use "recordsetobject.Update" or it's batch variant. Instead, I use "recordsetobject.execute 'stored_procedure' ". Yes?

For fun, and potential future profit, try to use Javascript (ok, Jscript) instead of VBS in any code samples, se vou plaix.
RadarBob is offline   Reply With Quote
Old 07-25-2002, 12:05 AM   PM User | #2
whammy
Senior Coder

 
Join Date: Jun 2002
Location: 41° 8' 52" N -95° 53' 31" W
Posts: 3,660
Thanks: 0
Thanked 0 Times in 0 Posts
whammy is an unknown quantity at this point
I'm curious, as to how you get them in the first place?

Since you sound like you don't know exactly what the options are, you could write each one to an array if you're looping through a database to create the <select> element, and then write that array to a hidden field and submit that along with the form...

Quote:

I understand the response object receives only those radio button & checkbox values that are "selected" - NOT the complete radio button (checkbox) set ... - I assume this is also true of <select>. If so, easy enough to set the "selected" property in script just prior to SUBMIT.
Now, for checkboxes with different names, that would work - but of course it wouldn't tell you what the user checked, so I don't see the point. It wouldn't work for radio buttons or select elements, I'd try my idea above, perhaps.

P.S. I still don't understand why you wouldn't KNOW what options you have in your select element?!?
__________________
Former ASP Forum Moderator - I'm back!

If you can teach yourself how to learn, you can learn anything. ;)

Last edited by whammy; 07-25-2002 at 12:08 AM..
whammy is offline   Reply With Quote
Old 07-25-2002, 04:57 AM   PM User | #3
RadarBob
Regular Coder

 
Join Date: Jun 2002
Location: Round Rock, Texas
Posts: 443
Thanks: 0
Thanked 0 Times in 0 Posts
RadarBob is an unknown quantity at this point
Quote:
P.S. I still don't understand why you wouldn't KNOW what options you have in your select element?!?
The user is adding to a list that starts out empty. When the form is submitted, the list could have zero things or it could have many. It simply depends on what the user entered.
RadarBob is offline   Reply With Quote
Old 07-25-2002, 06:31 AM   PM User | #4
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
I supposed you use javascript to do the adding of options programmatically.
you have 2 ways to do this:

#1:
you can have a hidden textbox that contains the added options separated by a comma or something. then in your submit page:

options = request.form("nameOfHidden")
//split using the delimeter used to make an array
arrOptions = split(options,",")
'do your processing here


#2:
make the select tag multiple-select
<select name="..." multiple>

then before submit, select all options using javascript
then in submit page:

for each item in request.form("nameOfSelect")
response.write item
'do your processing here
next



Quote:
Originally posted by RadarBob

The user is adding to a list that starts out empty. When the form is submitted, the list could have zero things or it could have many. It simply depends on what the user entered.
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 07-25-2002, 04:08 PM   PM User | #5
allida77
Regular Coder

 
Join Date: Jun 2002
Location: Cincinnati, OH
Posts: 545
Thanks: 0
Thanked 0 Times in 0 Posts
allida77 is an unknown quantity at this point
If you just do a

Request.Form("sltMultiple")

it will bring all values of the options selected in a list. Then you can split the list and use the UBound function to determine how many items were selected. I always use vbscript so I am not sure what the code is in jscript.
allida77 is offline   Reply With Quote
Old 07-26-2002, 01:26 PM   PM User | #6
RadarBob
Regular Coder

 
Join Date: Jun 2002
Location: Round Rock, Texas
Posts: 443
Thanks: 0
Thanked 0 Times in 0 Posts
RadarBob is an unknown quantity at this point
Quote:
Originally posted by allida77
If you just do a

Request.Form("sltMultiple")

it will bring all values of the options selected in a list. Then you can split the list and use the UBound function to determine how many items were selected. I always use vbscript so I am not sure what the code is in jscript.
OK! Now we're gettin' somewhere. So SELECT behaves like checkboxes and radio buttons; only those things selected get passed in the form.

And UBound will give me the # of elements in an array.


Glenngv;
I want to stay away from "special handling". In other words, SELECT is a list that already "knows" each separate entry in the SELECT list. Likewise with arrays. No special processing to parse the list required. So I want to use the properties and methods build into these objects to the greatest extent possible.

However, from my readings I get the distinct impression that when the form is SUBMITted it becomes a Response.form object. I strongly suspect this is no longer the same form with the same method and property attributes it had when it was an HTML form.

You see? When the data was SUBMITted, it was transform from the "document object model" form in HTML to an "ASP model" form that happens to be a sub-object of the ASP Response object. The question then becomes "how is the Response.form different from the HTML <form>? What properties and methods does it have?.... In a 991 page book on "professional" ASP they don't say squat about it.
RadarBob is offline   Reply With Quote
Old 07-26-2002, 02:30 PM   PM User | #7
allida77
Regular Coder

 
Join Date: Jun 2002
Location: Cincinnati, OH
Posts: 545
Thanks: 0
Thanked 0 Times in 0 Posts
allida77 is an unknown quantity at this point
http://www.devguru.com/Technologies/...uest_form.html

The Form is not a sub-object. It is just a collection of whatever values were submitted via the post method. The link above will gives you all the form collection properties.
allida77 is offline   Reply With Quote
Old 07-26-2002, 04:32 PM   PM User | #8
RadarBob
Regular Coder

 
Join Date: Jun 2002
Location: Round Rock, Texas
Posts: 443
Thanks: 0
Thanked 0 Times in 0 Posts
RadarBob is an unknown quantity at this point
Thanks, agent 77. I'm disappointed, but not suprised at the dirth of collection properties.
RadarBob is offline   Reply With Quote
Old 07-26-2002, 06:04 PM   PM User | #9
allida77
Regular Coder

 
Join Date: Jun 2002
Location: Cincinnati, OH
Posts: 545
Thanks: 0
Thanked 0 Times in 0 Posts
allida77 is an unknown quantity at this point
I am not sure what else you would want to do with a <form> server side besides read whatever post data is submitted. What are you looking for it to do?
allida77 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 01:05 PM.


Advertisement
Log in to turn off these ads.