PDA

View Full Version : passing variables


eel_22
02-13-2003, 11:12 AM
I am not sure which forum this should be posted onbut I'll give it a bash here...

I am currently designing a search function for a website I am working on. This search function consists of 3 pull down menus, each populated by the users selections

i.e. the user selects from the 1st menu (Flow Cv) which then populates the 2nd menu (Orifice size) with data corresponding to the 1st menu. They then select from this menu which populates the third menu.

Arrays with all the relevant data are sent with page and javascript is used to search through them.

i.e.
var arrItems1 = new Array();
var arrItemsGrp1 = new Array();

arrItems1[3] = "Orifice Size A";
arrItemsGrp1[3] = 1;
arrItems1[4] = "Orifice Size B";


Also on this page there is a form with a submit button which sends the information to an ASP page for processing. This ASP page will take the information selected and search my DB.

i.e This is a snippet of the code in the form

i.e
<form name=myChoices method="get" action="product.asp">

<td>
<B>Flow CV:
<SELECT id=firstChoice name=firstChoice onchange="selectChange(this, myChoices.secondChoice, arrItems1, arrItemsGrp1);">
<option value=0 SELECTED>[SELECT]</option>
<option value=1>Flow CV1</option>
<option value=2>Flow CV2</option>
<option value=3>Flow CV3</option>

</SELECT>
</TD><TD>

<B>---> Orifice Size:
<SELECT id=secondChoice name=secondChoice onchange="selectChange(this, myChoices.thirdChoice, arrItems2, arrItemsGrp2);">
<option value=0 SELECTED>[SELECT]</option></SELECT>

<B>---> Port Connection:
<SELECT id=thirdChoice name=thirdChoice> <option value=0 SELECTED>[SELECT]</option></SELECT>

<input type="submit" value="Get your Product">



Below here is my ASP page to give you an idea of where I am going with this project... This ASP page will take the information selected from the menus and search my DB.

<%

'build SQL statement - get from the MS Access DB all the details on the product selected in the drop-down menu

SQL_query ="SELECT *FROM Products WHERE '" &amp; Request.Form("firstChoice") &amp; "' AND Orifice_size = '" &amp; Request.Form("secondChoice") &amp; "' AND Port_Connection = '" &amp; Request.Form("thirdChoice") &amp; "'"


'Create connection name "MyConn"
'Load the resulting recordset into the variable RS

Set MyConn = Server.CreateObject("ADODB.Connection")
MyConn.Open "FILEDSN=C:\dsn\TestDB_dsn.dsn"

Set RS = MyConn.Execute(SQL_query)

If NOT rs.eof then
WHILE NOT RS.EOF

Response.Write "The following products are available <BR><BR> Product_id : " &amp; rs("Price") &amp; " "

RS.MoveNext
WEND
else


'tell the user that no products in the DB matched your selections

response.write "There are no products which match your selections"
end if

'close the rs and the db conn

RS.Close
MyConn.Close
%>


The problem I have is that I am not passing the correct variable to the ASP page and need some advice on how to do it as I am novice to Javascript.

Currently I am passing the number in the array corresponding to the users selection but I want to pass the string so that the ASP page can use this to search my DB and return results.

Any ideas?

ez4me2c3d
02-13-2003, 12:37 PM
you need to use the POST method in your form. I say this because you are using theRequest.Formwhich uses the POST method not the GET[code]Request.QueryString[.code]uses the GET method. try that and see if it works.

http://www.w3schools.com/asp/asp_inputforms.asp