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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refresh ASP page possible?

Status
Not open for further replies.

csiwa28

Programmer
Apr 12, 2001
177
Suppose I have an asp page with a list box with several choices (A, B, C) and if a user selects a choice then another list box on that same page will be populated with certain information?
 
First thought would be to have a condition in your page that checks if a passed parameter is set (eg ShowList2=True) then when the condition is checked, populate the list with what you wish, possibly with other parameter values passed.

Brian
 
This requires pure JavaScript.. Load this into your browser, examine the script and you should be able to determine how it's done..


<html>
<head>
<script Language=&quot;JavaScript&quot;>
<!--
function populateList2(form_ref) {

if (form_ref.months.value == &quot;&quot;) {
// IF &quot;SELECT MONTH&quot; IS SELECTED IN MONTHS LIST
form_ref.holidays.length = null
form_ref.holidays.options[0] = new Option(&quot;No Events Listed&quot;,&quot;&quot;)
} else {
// OTHERWISE EXAMINE SELECTION AND POPULATE 2ND LIST
if(form_ref.months.value == &quot;12&quot;) {
// CLEAR THE LIST
form_ref.holidays.length = null
// ADD OPTIONS HERE
form_ref.holidays.options[0] = new Option(&quot;Christmas&quot;,&quot;xmas&quot;)
form_ref.holidays.options[1] = new Option(&quot;Christmas Eve&quot;,&quot;xmaseve&quot;)
form_ref.holidays.options[2] = new Option(&quot;New Years Eve&quot;,&quot;nyreve&quot;)
form_ref.holidays.options[3] = new Option(&quot;My Friends Birthday&quot;,&quot;joesbday&quot;)
}
if(form_ref.months.value == &quot;4&quot;) {
// CLEAR THE LIST
form_ref.holidays.length = null
// ADD OPTIONS HERE
form_ref.holidays.options[0] = new Option(&quot;Good Friday&quot;,&quot;gfd&quot;)
form_ref.holidays.options[1] = new Option(&quot;Easter Sunday&quot;,&quot;esunday&quot;)
form_ref.holidays.options[2] = new Option(&quot;April Fools Day&quot;,&quot;apr1&quot;)
}
if(form_ref.months.value == &quot;11&quot;) {
// CLEAR THE LIST
form_ref.holidays.length = null
// ADD OPTIONS HERE
form_ref.holidays.options[0] = new Option(&quot;PGA Skins Game&quot;,&quot;skins&quot;)
form_ref.holidays.options[1] = new Option(&quot;Thanksgiving&quot;,&quot;thxgvng&quot;)
}
}
}



// -->
</script>
</head>

<body>
<form>
Months: <select name=&quot;months&quot; onChange=&quot;populateList2(this.form);&quot;>
<option value=&quot;&quot;>Select Month</option>
<option value=&quot;12&quot;>December</option>
<option value=&quot;4&quot;>April</option>
<option value=&quot;11&quot;>November</option>
</select><br><br>
Events: <select name=&quot;holidays&quot;>
<option value=&quot;&quot;>No Events Listed</option>
</select>
</form>
</body>
</html>


Hope this sheds some light on the subject..

TW

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top