mark wills wrote:

>Hi there.... I wonder if anyone can help with this tricky problem....
> 
>I have 3 list boxes which are populated by recordsets. However, the records added to 
>the third list box depends on what the user selected in the first and second list 
>boxes. (The values selected in the list boxes are used to 'build' an SQL query in the 
>normal way...)
> 
>At the moment, I have had to put a submit button next to the SECOND list box, that 
>he/she must click, which causes the form to be POSTed and the query built, thus the 
>third list box can be built with the correct data.
> 
>However, (and here's my problem!) I need ANOTHER submit button at the bottom of the 
>form, because the page in question is an 'add record' type of form (it's actually an 
>'add new problem' page to a maintenance database).
> 
>(sorry... I'll get to the point in a minute!!)
> 
>So, since I need a form post button to actually submit the form data to the next page 
>for processing, I can't have a submit button for the list box!!!
> 
>What I need is some clever javascript, that, when the second list box is changed, it 
>causes the form to be submitted to itself.
> 
>I've seen it on other websites, but don't have a clue how it works... I hate 
>JavaScript almost as much as I hate having no money ;-)
> 
>Can anyone suggest a solution?
>  
>

Have a separate form outside of the current form on your page.

<form name="Second_List_Form" method="post" action="this page">
<input type="hidden" name="First_List_ID" value="">
<input type="hidden" name="Second_List_ID" value="">
</form>

Then, in your current form, add the onchange event to the select:

<form name="Main_Form" method="post" action="wherever you want it to go">
<select name="First_List_ID" class="select" 
onchange="fncSubmitSecondListForm();">
<select name="Second_List_ID" class="select" 
onchange="fncSubmitSecondListForm();">
</form>

Javascript needed:

<script type="text/javascript">
<!-- hide me

// This is the car list in the banner
function fncSubmitSecondListForm()
{
  var i = window.document.Main_Form.First_List_ID.selectedIndex;
  var j = window.document.Main_Form.Second_List_ID.selectedIndex;
  if(i==0)
  {
    alert( "Please select an option, then press go.");
    return false;
  }
  else
  {
    window.document.First_List_Form.Second_List_ID.value = i;
    window.document.Second_List_Form.Second_List_ID.value = j;
    window.document.Second_List_Form.submit();
  }
}

// -->
</script>

Obviously, you need to change the action tags on the forms to the actual 
pages you want the forms to go to.

Looking at your problem, aren't you also going to need to do the same 
for the first listbox?

Hope that helps,

manzo


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/17folB/TM
--------------------------------------------------------------------~-> 

---------------------------------------------------------------------    
 Home       : http://groups.yahoo.com/group/active-server-pages
---------------------------------------------------------------------
 Post       : [EMAIL PROTECTED]
 Subscribe  : [EMAIL PROTECTED]
 Unsubscribe: [EMAIL PROTECTED]
--------------------------------------------------------------------- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/active-server-pages/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to