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 Page Based on Click In DropDown Box

Status
Not open for further replies.

JohnBates

MIS
Feb 27, 2000
1,995
US
Hi there ASP people,

I will try to explain what I need to do.

When the page loads, it determines the year in the current system date (so right now year is 2002 of course) and selects data for this year and builds the barchart.

There is also a dropdown box that is populated (with year values... 2001, 2002 etc)when the page loads. (though right now user clicks in the box dont do anything)

This much is working well... but I don't know how to make it more dynamic so the user can select a year from the dropdown box and have the page rebuild the barchart based on the new year the user selected in the box.
________________________________________________________
I guess my question is... How do I write the click-event code so I can get the year the user selected?

Seems simple, I know; but I cant find any good examples.

The solution just needs to work with the IE browser in an Intranet environment.

Thanks, John






 
Assuming your select/drop down is in a form, you can have a button or submit button to submit the form to the same page and request.form("selectname") to get the value provided in the option chosen.

Alternatively, you can use the onChange event of the select to submit your form when a different option is chosen:

<select name=&quot;selName&quot; onChange=&quot;formname.submit()&quot;>

Hope that helps...
 
Oh, to do it client side, use the onChange and then get the value by document.formname.selName.value in javascript.
 
To do it on the client-side using javascript, you can create different arrays for different values, & then based on the value selected in the drop down box, you can load a particular array in the drop down using the javascript.

Hitesh
 
Thanks for everyones ideas.

I do not need to rebuild the dropdown box. Need to call the subprocedures that do the SQL Select to retrieve the year's data the user selected in the dropdown.....and then redisplay the asp page.

but I don't really know how to use the onChange... how to code it.

Thanks, John
 
<select class=&quot;disclaimer&quot; name=&quot;YearSelection&quot; onChange=&quot;MM_jumpMenu('parent',this,0)&quot;>
<option value=&quot;pagename.asp?year=2002&quot; selected>2002</option>
<option value=&quot;pagename.asp?year=2003&quot; >2003</option>
<option value=&quot;pagename.asp?year=2004&quot; >2004</option>
<option value=&quot;pagename.asp?year=2005&quot; >2005</option>
<option value=&quot;pagename.asp?year=2006&quot; >2006</option>
</select>

************************************************
Whenever the user select the year from the dropdown list , it will call the page with the new year value
********************************************************
<script language=&quot;JavaScript&quot;>
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+&quot;.location='&quot;+selObj.options[selObj.selectedIndex].value+&quot;'&quot;);
if (restore) selObj.selectedIndex=0;
}
</script>
****************************************************
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top