Php/javascript Dynamic Drop Down

windows

Guest
Hi all-<br /><br />I'm having some trouble with a dynamic drop down box on one of my PHP pages.<br /><br />I've been searching the net for examples, but mostly I've been seeing ones that dynamically change another drop down box underneath it. (For example, choosing a make of car in box A, and having it automatically update box B with the available models.)<br /><br />I need it to do something different, not difficult, but just can't figure it out.<br />-----------<br /><br />The purpose of my page is to add a customer name & info to a mySQL database.<br />The user can either choose from an existing customer in the database or enter in a new one. <br />If the user chooses an existing customer, the PHP code will query the database, printing out all available customer names in a < SELECT > menu. Like thus (note: the code does not work properly):<br /><br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><tr><br />  <td class="heading" align=right>Choose previous: </td><br />  <td><br />       <form name="completeform" method="post" <br />                 action="sales.php?action=addproj&go=2"><br />       <select name="contact" class="data"><br />          <option value="">--Choose contact--<br /><br />  <?php<br />  //select all previous contacts<br />  $query = "SELECT ContactID,Company_Name <br />                  FROM ContactTable<br />                  ORDER BY 'Company_Name'";<br />       //run query<br />       rq($res,$query);<br />       while ($rows = mysql_fetch_array($res)){    <br />            $id = $rows['ContactID'];<br />            $compname1 = $rows['Company_Name'];<br />   ?><br />   <br />          <option value="<?php echo $id;?>"><?php echo $compname1;?><br /> <?php<br />} ?><br /><br /></select><input type=submit name=submit value="Complete"></form><br />   </td><br /></tr><!--c2--></div><!--ec2--><br /><br /><br />When the user clicks on an option in the select menu and clicks the 'complete' button, it should then reload the same PHP page, request the ID number, and fill in all appropriate information fields with the data with the ID from the select menu.<br /><br />This is not doing so. Notice I want the form to submit to 'sales.php?action=addproj&go=2'? Well, after the click of 'Complete', the form is actually submitting to 'sales.php?action=addproj&go=1&id=&flag=', which is the submit value of another form outside of this code! I guess you can't nest forms or something?? Mad!!! <br /><br />Can anyone provide any input? I've even tried JavaScript, but I can't get it to reload the PHP page & send the ID variable.<br /><br />If anyone wants to see the page, I will provide more code or send a link.<br /><br />Thanks in advance!<!--content-->
<!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->This is not doing so. Notice I want the form to submit to 'sales.php?action=addproj&go=2'? Well, after the click of 'Complete', the form is actually submitting to 'sales.php?action=addproj&go=1&id=&flag=', which is the submit value of another form outside of this code! I guess you can't nest forms or something??<!--QuoteEnd--></div><!--QuoteEEnd--><br /><br />Hm...you lost me at Hi...<br /><br />for the problem above..make sure you have different submit names. <br /><input type=submit name=submit value="Complete"> change to <br /><input type="submit" name="submitwhatever" value="complete"><br /><br />and if you of course if u want to manipulate any of those post variable...<br />Check to see if form was submitted like so, <br />if (isset($_POST['submitwhatever'])) or something similar.<br /><br />If that doesn't help...sorry<!--content-->
I tried different submit names just now. Didn't work..... I'm still getting the same response.<!--content-->
hm...well i knwo its something nitpicky...how about form names..u are using different ones right? cause if you isolate that form...it works fine.<!--content-->
Yeah, I've tried different form names and now different submit names. <br /><br />Do you know of a way to bypass the form submitting with just using <br />JavaScript? Like if I put an onClick button or the onChange handler in the 'select' tag that will reload the page? I tried it once but I kept getting errors.<!--content-->
hm...yeah thats possible..but I never do that so i couldn't tell you.. but i always have mutliple forms on my sctipts with no problems...could u private message me the url...or u can get on aim and get it to me...my user is sectiond31.<!--content-->
 
Back
Top