Passing form variable between pages

This is a discussion on "Passing form variable between pages" within the Classic ASP section. This forum, and the thread "Passing form variable between pages are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Dec 16th, 2003, 06:21
New Member
Join Date: Dec 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Passing form variable between pages

Iv’e been using rob's functions for passing variables between pages.

I am not much of a ASP man, so maybe the following question is a stupid one, but I still gonna try.

I have a form with some select fields. The labels and the values are not the same on these select fields.

For example:
Select1 has 5 options

Text1 value = 10.00
Text2 value = 20.00
Text3 value = 30.00
Text4 value = 40.00
Text5 value = 50.00

When submitting the form I want to get both the text as the values on the other page.

Can this be done.

I would apreciate any help.

  #2 (permalink)  
Old Dec 16th, 2003, 07:12
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
So you want both the displayed text and the value from the selected item on the next page?

If so you'll want to modify the values to include the text, then separate it back out on the second page.
Code: Select all
<item value="Text1|10.00">Text1</item>
<item value="Text2|20.00">Text2</item>
<item value="Text3|30.00">Text3</item>
then on the next page
Code: Select all
s = request.form("fieldname")
text = left(s,instr(s,"|")-1)
value = right(s,len(s)-instr(s,"|"))
There's other ways to do it, but that one's simple enough.
  #3 (permalink)  
Old Dec 16th, 2003, 09:27
New Member
Join Date: Dec 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Tnx for the quick reply Catalist.. but no succes yet
I get nothing on the other page.
Maybe i explained wrong.. i want to split the label and the value from each other on the next page

This is my code on page 1

<form name="form1" method="post" action="form2.asp">
<select name="something">
<option value="Text1|10.00">Text1</option>
<option value="Text2|20.00">Text2</option>
<option value="Text3|30.00">Text3</option>
</select>


and yours on page 2
<%
s = request.form("something")
text = left(s,instr(s,"|")-1)
value = right(s,len(s)-instr(s,"|"))

%>
  #4 (permalink)  
Old Dec 16th, 2003, 13:15
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
i take it your are actually writing out the values of text and value?

Response.Write text
Response.Write value
  #5 (permalink)  
Old Dec 16th, 2003, 13:26
New Member
Join Date: Dec 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
yes
  #6 (permalink)  
Old Dec 16th, 2003, 14:06
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
This is actually what is required on page 2:-
Code: Select all
<%
s = Split(request.form("something"),"|")
text = s(0)
value = s(1)

Response.write text & " : " & value
%>
Hope this helps.
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
  #7 (permalink)  
Old Dec 16th, 2003, 14:35
New Member
Join Date: Dec 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
yep, both examples work, only now i stumbled opon the next problem.
On the first page i do a calculation of prices (the value part)before submitting them to the next page, but that doesnt work any more because we put the text in there aswell.
And that's where i wanted to split up text and value.
i will try to tell exactly what and where i need this for.

I have a website where people can rent a gameserver.
I made a little form with the following formfields
A select/list box called "game" with names of the game servers, the prices are the values of this select box.
A Select/list box called "Privpubl" where there are 2 choices, private server or public server. The value of private server = 0.00 and public = 30.00.
A select/list box called "players" where the text = number of player (16,18, etc) and the values are 0.00,3.00,6.00, etc.
And a textfield called "result"

When people make selections from which server they want the form adds the values and put them into the result field.

When they made there final selection they can submit the form.
On the next page i want to split the values and the text into different form fields.
After that i want to submit all that data into a SQL database (that's no problem btw)

So i hope you see my problem, i cannot put text|value in the value part of a select/list boxor else my calculating gets scr*wed up.
  #8 (permalink)  
Old Dec 16th, 2003, 14:38
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
Can you post a txt version of both pages here? (or link to a txt version of them)

Cheers,
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
  #9 (permalink)  
Old Dec 16th, 2003, 14:59
New Member
Join Date: Dec 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Ok here they come
Page 1 is http://www.ultimateservers.nl/test/form1.txt
Page 2 is http://www.ultimateservers.nl/test/form2.txt

They are a bit big because i made a txt version of the complete pages.
If you go to my site www.ultimateservers.nl and click on game servers in the left colum you see the calculation form

Tnx for al your help..
Closed Thread

Tags
passing, form, variable, between, pages

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 On

Similar Threads
Thread Thread Starter Forum Replies Last Post
form variable within an iframe component of a form kissfreaque JavaScript Forum 5 Feb 29th, 2008 11:57
passing data accross multiple pages nate2099 PHP Forum 2 Jul 8th, 2007 15:26
Variable passing VanderBOOM JavaScript Forum 20 Nov 2nd, 2006 21:39
Passing a Variable to ASP Smog36 Flash & Multimedia Forum 1 Sep 13th, 2006 14:05
[SOLVED] Passing my variable, help please Anonymous User PHP Forum 0 Feb 12th, 2005 13:37


All times are GMT. The time now is 04:47.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43