Sarah Posted April 28, 2004 Posted April 28, 2004 Hi all- I'm having some trouble with a dynamic drop down box on one of my PHP pages. 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.) I need it to do something different, not difficult, but just can't figure it out. ----------- The purpose of my page is to add a customer name & info to a mySQL database. The user can either choose from an existing customer in the database or enter in a new one. 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): ><tr> <td class="heading" align=right>Choose previous: </td> <td> <form name="completeform" method="post" action="sales.php?action=addproj&go=2"> <select name="contact" class="data"> <option value="">--Choose contact-- <?php //select all previous contacts $query = "SELECT ContactID,Company_Name FROM ContactTable ORDER BY 'Company_Name'"; //run query rq($res,$query); while ($rows = mysql_fetch_array($res)){ $id = $rows['ContactID']; $compname1 = $rows['Company_Name']; ?> <option value="<?php echo $id;?>"><?php echo $compname1;?> <?php } ?> </select><input type=submit name=submit value="Complete"></form> </td> </tr> 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. 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!!! 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. If anyone wants to see the page, I will provide more code or send a link. Thanks in advance! Quote
section31 Posted April 28, 2004 Posted April 28, 2004 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?? Hm...you lost me at Hi... for the problem above..make sure you have different submit names. <input type=submit name=submit value="Complete"> change to <input type="submit" name="submitwhatever" value="complete"> and if you of course if u want to manipulate any of those post variable... Check to see if form was submitted like so, if (isset($_POST['submitwhatever'])) or something similar. If that doesn't help...sorry Quote
Sarah Posted April 28, 2004 Author Posted April 28, 2004 I tried different submit names just now. Didn't work..... I'm still getting the same response. Quote
section31 Posted April 28, 2004 Posted April 28, 2004 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. Quote
Sarah Posted April 28, 2004 Author Posted April 28, 2004 Yeah, I've tried different form names and now different submit names. Do you know of a way to bypass the form submitting with just using 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. Quote
section31 Posted April 28, 2004 Posted April 28, 2004 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.