cfgcjm Posted January 23, 2008 Share Posted January 23, 2008 I am looking to have one of the following setups: The values in the combo box on the left and the yes/no in either object on the left are stored in the database they are being read from. What i want to happen is if a user were to change the combo box on the left the object on the right would update to reflect it's value in the database. I have no clue how to get the object on the right to change based on the data in the database and the changing of the combo box with the names...I was told it's javascript so i was hoping someone here could help Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted January 23, 2008 Share Posted January 23, 2008 you cannot do this with javascript alone; you need ajax (which is javascript and a server side language, such as php). Quote Link to comment Share on other sites More sharing options...
cfgcjm Posted January 23, 2008 Author Share Posted January 23, 2008 I'm already using php, i just dont know where to go from here: <?php $session = mysql_connect("localhost", "digiconm_admin", "33gaylan1"); mysql_select_db("digiconm_homeplate"); $query = "select * from users"; $result = mysql_query($query); if ( !$result ) { echo ( "<P>Error doing a select: " . mysql_error() . "</P>" ); } else { // succesful read - how many records ? print (" Number of rows read " . mysql_num_rows($result)."</br>"); $rr=mysql_num_rows($result); //this is calculating the number of rows read from database and puts it into variable rr // loop over rows, counts the total number and prints them $user = array(); // define array students for ($i=0; $i<$rr; $i++) { $nextresult = mysql_fetch_array($result); $fname = $nextresult['first_name']; $lname = $nextresult['last_name']; $journal = $nextresult['client']; $username="$lname, $fname"; $user[$i] = $username; $client[$i]=$journal; echo"$user[$i] - $client[$i]\n"; } } mysql_close($session); sort($user); ?> <html> <head> </head> <body> <form name="form" method="post" action=""> <select name="name" id="name"> <?php foreach ( $user as $user_name ) { echo "<option>{$user_name}</option>"; } ?> <option selected "$user_input"></option> </select> <fieldset name="Group"> <legend></legend> Yes<input name="Yes" type="radio" id="yes" checked="checked" value="1"> No<input name="Yes" type="radio"id="yes"> </fieldset> <input name="change" type="button" value="Change"></form> </body> </html> Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted January 23, 2008 Share Posted January 23, 2008 read up on ajax Quote Link to comment Share on other sites More sharing options...
taith Posted January 23, 2008 Share Posted January 23, 2008 you'd put an onchange="" tag onto your select, running an ajax script which'd load the "php" file, dropping in the dropdown/radio buttons :-) Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted January 23, 2008 Share Posted January 23, 2008 you'd put an onchange="" tag onto your select, running an ajax script which'd load the "php" file, dropping in the dropdown/radio buttons :-) yeah, that would work; but cfgcjm has too learn a little bit of ajax to accomplish this. cfgcjm, do a little google'n for ajax to see a few examples. Quote Link to comment Share on other sites More sharing options...
taith Posted January 23, 2008 Share Posted January 23, 2008 agreed... i'm just trying to give some ideas of where to aim at Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted January 23, 2008 Share Posted January 23, 2008 agreed... i'm just trying to give some ideas of where to aim at works for me Quote Link to comment 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.