PDA

View Full Version : retrieve fields


ooiooipig
03-21-2003, 01:29 AM
Hi all, I hope that there's someone who can help me. I'm doing a project which require to use vbscript in asp to retrieve some fields when clicking onto certain links.

For example, there are 3 links, "A", "B" and "C".
When i click onto link A, it brings me to the next page and this page displays all the fields require to be field in by the users.
However, when i click onto link B or C, there'll be certain fields displayed for users to enter the particulars and not all the fields.

I'm intending to use vbscript to retrieve the fields when users click onto their desired link. is there any other better recommendations??

any help will be greatly appreciated ??
Thanks!!

glenngv
03-21-2003, 07:20 AM
use query string!

<a href="myfile.asp?m=1">A</a>
<a href="myfile.asp?m=2">B</a>
<a href="myfile.asp?m=2">C</a>

then in myfile.asp:

mode = request.querystring("m")
if mode<>"1" and mode<>"2" then mode="1" 'put default value

if mode="1" then
'display all fields
else
'display some fields
end if

ooiooipig
03-21-2003, 08:28 AM
Hi Glenn, thanks for your reply!!
But what if for the selection of A,B,C that part, I'm using a select drop down menu to let users to select?

raven
03-21-2003, 08:35 AM
Then you'd use request.form instead.

ooiooipig
03-21-2003, 08:37 AM
Hi Raven, thanks for your reply...

but how should I go about using request.form??

raven
03-21-2003, 08:42 AM
In original page:

<select name="combo">
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
</select>

the in form target page:

variable = Request.Form("combo")

david7777
03-21-2003, 09:00 AM
Then in the page with the form with fields for the user:

You must have if statements:


formType = Request.Form("combo")

if formType = "1" then
<input type="textbox" name="id"....> ' Only shows if type 1
end if

<input type="textbox" name="name"....> ' Shows for type 1,2 and 3
<input type="textbox" name="lastName"....> ' Shows for type 1,2 and 3

if formType = "2" then
<input type="textbox" name="orderCode"....> ' Only shows if type 2
end if

if formType = "3" then
<input type="textbox" name="invoiceNumber"....> ' Only shows if type 2
end if


I think this is what you are looking for... This will mean that if the user chooses type 1, then the name, lastName and id text boxes will show. If they select type 2, then name, lastName, and orderCode text boxes will show. If they select 3, name, lastName and invoiceNumber will show.

:cool:

ooiooipig
03-21-2003, 09:02 AM
yah Raven, I've got that (passing of variable) done but how can I display the fields required when I've selected the individual selection??

ooiooipig
03-21-2003, 09:03 AM
Thanks David!! That's exactly what i want!! thanks alot... I'll go and give it a try.

ooiooipig
03-21-2003, 09:16 AM
David, the codes that you've written are to be placed within a <%%> or not?? Where should it be placed under??

ooiooipig
03-21-2003, 09:19 AM
David, can I just have a complete form if I choose "1" and then from the complete form, I get the fields out for option "2" and "3"??

david7777
03-21-2003, 09:34 AM
Oh - sorry about that - Here is how it should be:

<%
formType = Request.Form("combo")

if formType = "1" then%>
<input type="textbox" name="id"....> ' Only shows if type 1
<%end if%>

<input type="textbox" name="name"....> ' Shows for type 1,2 and 3
<input type="textbox" name="lastName"....> ' Shows for type 1,2 and 3
<%
if formType = "2" then%>
<input type="textbox" name="orderCode"....> ' Only shows if type 2
<%end if

if formType = "3" then%>
<input type="textbox" name="invoiceNumber"....> ' Only shows if type 2
<%end if%>


About your next question - I dont fully understand what you are asking?

ooiooipig
03-24-2003, 01:40 AM
hi David,

thanks for your help, regarding the 2nd question, I was thinking if I can have a standard form (for the 1st option), then from there I select the fields from the standard form for the other 2 options??

example:

option 1: name field, address field, contact number field and postal code field.

option 2: name field and address field only

option 3: contact number field and postal code field only.

the fields in option 2 and 3 are the same as the ones in option 1, therefore, they just retrieve from option 1.

thanks for your help!!

ooiooipig
03-24-2003, 06:02 AM
it's ok already David!! thanks alot for your help!!

ooiooipig
03-24-2003, 06:21 AM
thanks to all the people who have helped me in this thread. I've got another problem. Please help if can.
Thanks!!