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!

create variable from user selection

Status
Not open for further replies.

Dashsa

Programmer
Aug 7, 2006
110
US
Hello,
I have a page with a drop down that allows users to select a job and then they will get redirected to the apropriete page from this selection.
my siiue is with collecting the data from the drop down and making it a variable.
I can do this of I use a form and send them to a processing page but I am try to do this on the same page.

What I have so far is the drop down getting populated by a Database that gives the values. Now I need to pass the value selected to a redirect page (Session Variable) as I will use it in a SQL statement.
Thanks for looking!
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<%@language = JScript%>
<!--#include file="adojavas.inc"-->
<html>
<head>
<title> </title>
<link href="job.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style3 {
font-family:Arial, Helvetica, sans-serif;
font-size: 15px;
font-weight: bold;
color: #006666;
}
-->
</style>
<%
Session("S_user")
Session("S_pass")
Session("S_jobname")
// this code checks that a valid user is logged in.
var jobName = Session("S_jobname")
//if(!Session("S_user")){
//Response.Redirect("../../login.html");
//}
//else{
//}

var connect = Server.CreateObject("ADODB.Connection");
var recordSet = Server.CreateObject("ADODB.RecordSet");
connect.Open("DSN=btvDB");
recordSet.Open("select DISTINCT jobCode from JobsiteLog",connect,adOpenKeyset,adLockOptimistic);

%>
<script type="text/javascript">
function reDirect(){
zoo = form.jobsite.value;
alert(zoo);
}

</script>
</head>
<body>
<div class="Wrapper">
<!-- Main Banner -->
	<div id="HeadBanner">
	<img src="../Images/headBanner.png" width="964" height="128" alt="">
	</div>
<!-- END Main Banner -->
		<!--  Begin of Navigation Div Bar -->
		<div class="style3" id="NavBar"> 
      	<center>
       	HOME&nbsp;&nbsp;&nbsp;ADD LOG
       	</center>
       	</div>
	<!-- End Nav bar -->

<div class="addJobLog">
<center>
<form onSubmit="reDirect(this)" action="" method="post" name="">
//************************************ THIS IS WHERE I NEED HELP!!!!*****************************************
	<select name="jobsite">
	<option value="PLEASE SELECT A JOB">PLEASE SELECT A JOB</option>
<%
	while(!recordSet.EOF)
		{
				code = recordSet("jobCode")
				Response.Write("<option name='" + code + "'>");
				Response.Write(code);
				Response.Write("</option>");
				recordSet.MoveNext();
		 }
		%>
		</select>
        <input type="button" value="Submit" onClick="reDirect()">
        </form>
        </center>
</div>
</div>
</body>
</html>

[code]
 
Try posting the generated HTML instead of your VB ASP.
so when know what's actually happening.

Anyway, You could get the value from the drop down, and append it to the url redirect as a parameter thus obtaining the value in the query string as if you had submitted a form using the GET method.

Code:
window.location="[URL unfurl="true"]http://www.server.com/pagename.xxx?paramname="[/URL] + document.getElementById('dropdownid').value;








----------------------------------
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.
 
thanks,
Actually I am not using vb ASP but rather JSCRIPT , anyway I got it to work by :
Code:
function reDirect(){

var cc= document.formName.jobsite.options[document.formName.jobsite.selectedIndex].value;

//alert the value needed for testing purpose
alert(cc)

}

Full code below.


Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<%@language = JScript%>
<!--#include file="adojavas.inc"-->
<html>
<head>
<title> </title>
<link href="job.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style3 {
font-family:Arial, Helvetica, sans-serif;
font-size: 15px;
font-weight: bold;
color: #006666;
}
-->
</style>
<%
Session("S_user")
Session("S_pass")
Session("S_jobname")
// this code checks that a valid user is logged in.
var jobName = Session("S_jobname")
//if(!Session("S_user")){
//Response.Redirect("../../login.html");
//}
//else{
//}

var connect = Server.CreateObject("ADODB.Connection");
var recordSet = Server.CreateObject("ADODB.RecordSet");
connect.Open("DSN=btvDB");
recordSet.Open("select DISTINCT jobCode from JobsiteLog",connect,adOpenKeyset,adLockOptimistic);

%>
<script type="text/javascript">
function reDirect(){

var cc= document.formName.jobsite.options[document.formName.jobsite.selectedIndex].value;
alert(cc)

}

</script>
</head>
<body>
<div class="Wrapper">
<!-- Main Banner -->
	<div id="HeadBanner">
	<img src="../Images/headBanner.png" width="964" height="128" alt="">
	</div>
<!-- END Main Banner -->
		<!--  Begin of Navigation Div Bar -->
		<div class="style3" id="NavBar"> 
      	<center>
       	HOME&nbsp;&nbsp;&nbsp;ADD LOG
       	</center>
       	</div>
	<!-- End Nav bar -->

<div class="addJobLog">
<center>
<form onSubmit="reDirect(this)" action="" method="post" name="formName">

	<select name="jobsite">
	<option value="PLEASE SELECT A JOB">PLEASE SELECT A JOB</option>
<%
	while(!recordSet.EOF)
		{
				code = recordSet("jobCode")
				Response.Write("<option name='" + code + "'>");
				Response.Write(code);
				Response.Write("</option>");
				recordSet.MoveNext();
		 }
		%>
		</select>

  <input type="button" value="Submit" onClick="reDirect(this)">
        </form>
        </center>
</div>
</div>
</body>
</html>

thanks again for looking.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top