Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Javascript Variable in ASP Querystring


Message #1 by "Ray Murphy" <raymurphy@g...> on Wed, 15 May 2002 14:23:15
You can always pass variables in a javascript function, if you need to
specify different posts:

<script language=javascript>
<!--

function getvalueCARRIER(list){

value = list.options[list.selectedIndex].text
sDate = document.thisForm.txtStartDate.value
eDate = document.thisForm.txtEndDate.value
	
location= "resultCARRIER.asp?CARRIER=" + value + "&" + "STARTDATE=" +
sDate + "&" + "ENDDATE=" + eDate
}

//-->
</script>

-----Original Message-----
From: Ray Murphy [mailto:raymurphy@g...] 
Sent: Wednesday, May 15, 2002 2:23 PM
To: javascript
Subject: [javascript] Javascript Variable in ASP Querystring

Stuck again :))

I've got an asp page which allows the user to select a year from a 
dropdown list, as in th code below :

<SCRIPT LANGUAGE="JavaScript">

function build_years_list()
{
	var thisYear, i

	// get current date
	date=new Date()	
	
	// year 2000 problem in old versions of netscape
             // (Netscape returns 101 for the year 2001)
	if(date.getYear()<1000)
	{
		thisYear = date.getYear() + 1900;
	} else {
		thisYear = date.getYear();
	}

	// write beginning of year-combo
	document.write('<select name=\"YearDropDown\">')

	// loop through each year, but the latest year MUST be
	// 18 years to the calendar year to reflect the fact 
	// that applicants must be 18 years old.
	for(i=1901;i<=thisYear - 18;i++) {
	
		document.write('<option value=\"' + i + '\">' + i
                      +'</option>')
	}

	// have now got all the years, so close the SELECT tag
	document.write('</select>') 
}

</SCRIPT>

What I need to do is take year selected by the user and pass it to
another
asp page, by tacking the year value onto the querystring for that page.
Given the code below, can anyone please advise how would I achieve this,

or if there is a better way to do this ?

<FORM NAME="Details" ACTION="UseYear.asp" METHOD="POST">
    <FONT face=Verdana size=2>Choose Year  </FONT>
    
    <SCRIPT language="JavaScript">
        build_years_list();
    </SCRIPT>
    </FONT>
    
  
<input TYPE="SUBMIT" VALUE="UseYear">
</FORM>

Thanks (and hoping) in advance .....

Ray

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20



  Return to Index