Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

newbie: pass value from drop down list to next page

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
I have a drop down list "ddSelectState" that I'm filling from access database. Using VBscript (I know, evil word here)
Anyway "Front Page" made a javascript routine MM_jumpMenu that redirects to a page directly after it's picked from the dropdown list. In this case I'm gong to the same page no matter which state they choose. But I want to get the value from the drop down list and pass it to the next page preferably by session variable which is the "StateChosen" on the next page.
here is the code I have.

Code:
<script  type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  //session["StateChosen"] =selObj.text [COLOR=red] I tried adding it here but then it does not redirect to next page[/color]
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>

<%'get states from db
	State=request.querystring("State")
	response.write State
	rtnCompany =Session("company")

	Set fp_conn =  Server.CreateObject("ADODB.Connection")
	fp_conn.Open Application("IHDatabase_ConnectionString")
	Set fp_rs_Facility = Server.CreateObject("ADODB.Recordset")
	Set fp_rs_Analyte = Server.CreateObject("ADODB.Recordset")

	SQLStringFacility = "SELECT  Company, FacilityState FROM IndustrialHygiene GROUP BY  Company,FacilityState HAVING Company = '" & rtnCompany & "';"
	fp_rs_Facility.Open SQLStringFacility, fp_conn, 1, 3, 1 
	fp_rs_Facility.movefirst
'response.write SQLStringFacility 
%>
<form name=form1>
<p class=MsoNormal align=center><span
	style='font-family:"Times New Roman","serif";color:windowtext'>
	<SELECT NAME="ddSelectState" onChange="MM_jumpMenu('parent',this,0)" size="1">
	<option value="Choose State" selected>Choose State</option>
	<%do while not fp_rs_Facility.EOF%>
		<OPTION VALUE="../ihexcel.asp"><%=fp_rs_Facility("FacilityState")%></option>
	<%fp_rs_Facility.movenext%>
	<%loop%>	
</SELECT></span></p>

</p>
</select>

</form>

DougP
[r2d2] < I Built one
 
No offense but really Frontpage? (nothing worse than FrontPage for web development)

JS has no idea what a VB session would be.
Here for a simpler to understand way of doing this:

Assuming your final HTML looks like:
Code:
<select onChange="Myredirect_func(this);">
<option value="firstvalue">Option 1</option>
<option value="secondvalue">Option 2</option>
...
</select>

Then in the JS function:
Code:
function Myredirect_func(mydropdown){
window.location="[URL unfurl="true"]http://www.server.com/mypage.asp?[/URL][red]myvalue[/red]=" + mydropdown.value;
}


That would pass the value through the querystring to the next page.





----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Ah Come on now, wez cain't a-ford 'hem faincy pro-grums,
I actually use a combination of programs including FP.

Thanks vacunita ,that worked great

DougP
[r2d2] < I Built one
 
DougP said:
Ah Come on now, wez cain't a-ford 'hem faincy pro-grums,
I actually use a combination of programs including FP.

I know you were kidding, but if you want something cheaper than FP, use Notepad - it's free and I'd use it over frontpage any day of the week.



--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search on, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
vicvirk said:
I know you were kidding, but if you want something cheaper than FP, use Notepad - it's free and I'd use it over frontpage any day of the week.
Definitely.


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Or, learn how to use Eclipse - It's also free, supports CVS and SVN syncronisation out-of-the-box, and has structured text editors and syntax highlighting for HTML, CSS, JS, JSP, & PHP.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top