First you must make the form submit to the page it's on:
<form action="<%=Request.ServerVariables("SCRIPT_NAME")% >">
I'd recommend creating a javascript function to handle the form's events and utilizing a hidden form field to save which event was fired:
<input type="hidden" name="hidFormEvent">
<script language="javascript">
function doPostBack(sEvent, objForm){
objForm.hidFormEvent.value = sEvent;
objForm.submit();
}
</script>
In the list box, you can force the form to submit with some javascript:
<select name="lstMyChoices" size="10" onChange="doPostBack('lstMyChoices_Changed',this.f orm);">
Then can write the form processing code on this page to accomodate what happens on the post back submit. Presumably you will have some button on the page as well as the list box, so you can add that into the post processing logic.
<input type="submit" name="cmdSaveStuff">
One of the nice things about submit buttons (and images) is that their value's aren't submitted unless they are actually clicked. So you can have 10 submit buttons on the page, they will all submit the form, but only the button that was clicked will appear in the Request.Form() collection. So this we can incorporate into the form processing code.
'First check for a form post
If Request.ServerVariables("CONTENT_LENGTH") > 0 Then
'Pick event
Select Case Request.Form("hidFormEvent")
Case "lstMyChoices_Changed"
'Do what you need when you change the list box selection
End Select
If Request.Form("cmdSaveStuff") <> "" Then
'Put your save logic here.
End If
End If
Peter
------------------------------------------------------
Work smarter, not harder.
|