portabletelly Posted May 24, 2007 Share Posted May 24, 2007 I have a form with a go button which echo's two variables for customer and tech when I submit the form. However my intention is to choose a tech in the select option "><select type="submit" name="ChooseTech" size="1" onChange="do somthing here"> then echo the content to the page without having to hit the go button. I belive I need to use Onchange but not matter what I type in for onchange= nothing seems to happen. Ideally I would like to choose a tech from the dynamic list then call a function which outputs the contents under echo $tech; echo $customer; Does anyone have any ideas how I could do that? <html> <head> <title>Manage Queues</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="Designed by Aaron Portelli" content="Portal HelpDesk"> <link rel="stylesheet" type="text/css" href="../style.css" /> <?php include("connect.php"); include("selectdb.php"); include("functions.php"); ?> </head> <body> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table width="100" border="0" cellspacing="0" cellpadding="1"> <tr> <td width="25%"><b>Tech_Queue</b> </td> <td width="25%"><b>Customer_Queue</b></td></td> <td></td> </tr> <tr> <td width="25%"><select type="submit" name="ChooseTech" size="1" onChange="do somthing here"> <?PHP echo ChooseTech(); ?> </select></td> <td width="25%"><select name="ChooseCustomer" size="1" onChange="do somthing here"> <?PHP echo createList(); ?> </select></td> <td width="50%"></td> </table> <br> <input type="submit" name="command" value="GO!" class="button" /> </form> <h1> </h1> <?php $tech = htmlspecialchars($_POST['ChooseTech']); $customer = htmlspecialchars($_POST['ChooseCustomer']); echo $tech; echo $customer; ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/52805--/ Share on other sites More sharing options...
craygo Posted May 24, 2007 Share Posted May 24, 2007 Give your form a name then do this <select name="ChooseCustomer" onChange="document.formname.submit()"> i think you will only be able to use this on the last select. But also if someone selects the last one first, it will submit. Ray Quote Link to comment https://forums.phpfreaks.com/topic/52805--/#findComment-260690 Share on other sites More sharing options...
taith Posted May 24, 2007 Share Posted May 24, 2007 onchange=javascript changing content without reloading=javascript/ajax Quote Link to comment https://forums.phpfreaks.com/topic/52805--/#findComment-260692 Share on other sites More sharing options...
portabletelly Posted May 24, 2007 Author Share Posted May 24, 2007 Thanx craygo seems to work. taith what do you mean by changing content without reloading=javascript/ajax Quote Link to comment https://forums.phpfreaks.com/topic/52805--/#findComment-260697 Share on other sites More sharing options...
craygo Posted May 24, 2007 Share Posted May 24, 2007 php is a server side script, so anytime you want to show new content on the page your have to "submit" what you want. With java, it is client side, so data gets stored in the browser and if you want to change content you can do so without submitting it back to the server for update. Ray Quote Link to comment https://forums.phpfreaks.com/topic/52805--/#findComment-260703 Share on other sites More sharing options...
portabletelly Posted May 24, 2007 Author Share Posted May 24, 2007 Not sure if this is going to work because the onchange is client side. What I now want to do is if a user chooses a tech <select name="ChooseTech" onChange="document.ct.submit()"> then a mysql query is run which echo's the outputs pn the same page for all the calls for that tech. Any idea how I would do that or if its possible? <html> <head> <title>Manage Queues</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="Designed by Aaron Portelli" content="Portal HelpDesk"> <link rel="stylesheet" type="text/css" href="../style.css" /> <?php include("connect.php"); include("selectdb.php"); include("functions.php"); ?> </head> <body> <table width="100" border="0" cellspacing="0" cellpadding="1"> <tr> <td width="25%"><b>Tech_Queue</b> </td> <td width="25%"><b>Customer_Queue</b></td></td> <td></td> </tr> <tr> <td width="25%"><form action="<?php echo $_SERVER['PHP_SELF']; ?>" name="ct" method="post"> <select name="ChooseTech" onChange="document.ct.submit()"> <?PHP echo ChooseTech(); ?> </select></form></td> <td width="25%"><form action="<?php echo $_SERVER['PHP_SELF']; ?>" name="cc" method="post"> <select name="ChooseCustomer" onChange="document.cc.submit()"> <?PHP echo createList(); ?> </select></form></td> <td width="50%"></td> </table> <br> <input type="submit" name="command" value="GO!" class="button" /> <h1> </h1> <?php $tech = htmlspecialchars($_POST['ChooseTech']); $customer = htmlspecialchars($_POST['ChooseCustomer']); echo $tech; echo $customer; ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/52805--/#findComment-260706 Share on other sites More sharing options...
trq Posted May 24, 2007 Share Posted May 24, 2007 You need to submit the form to a script which runs your query. As you said, OnChange is client side, while php is server side. Hence, to run php scripts you'll need to make a new request to the server. Quote Link to comment https://forums.phpfreaks.com/topic/52805--/#findComment-260709 Share on other sites More sharing options...
craygo Posted May 24, 2007 Share Posted May 24, 2007 There is not problem mixing javascript with php. The onchange is javescript so what you do is put a check to see if the form has been submitted. <?php if(isset($_POST['ChooseTech'])){ // Run mysql query below } else { // Show your original form below } ?> Ray Quote Link to comment https://forums.phpfreaks.com/topic/52805--/#findComment-260710 Share on other sites More sharing options...
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.