eits Posted September 5, 2007 Share Posted September 5, 2007 Hello, I have a field with a selectbox which contains a list of client names and several other fields which display information from the DB. I need to be able to make the fields change to the appropriate information when a user is selected from the select box. Can anybody please give me an example of a bit of code that will do this? Many Many Thanks in Advance!!! Quote Link to comment https://forums.phpfreaks.com/topic/68048-fill-fields-when-user-selects-user-from-db/ Share on other sites More sharing options...
vijayfreaks Posted September 5, 2007 Share Posted September 5, 2007 Hi.. I m not sure what you wanna do.. but if that mean if some one selected whatever from selectbox that would be retain as it is afer post back.. that you want to say..? or any thing else.. if yea then that would be done via.. <?php while{$rs=mysql_fetch_array($result)) { $val_from_db_loop = $rs['select_val']; ?> <option value="<?php echo $val_from_db_loop;?>" <?php if($_POST['select_box_name']==$val_from_db_loop) { ?> selected="selected" <?php } ?> > <?php echo $rs['select_show_val'];?> </option> } Regards, Vijay Quote Link to comment https://forums.phpfreaks.com/topic/68048-fill-fields-when-user-selects-user-from-db/#findComment-342038 Share on other sites More sharing options...
xyn Posted September 5, 2007 Share Posted September 5, 2007 Look-up AJAX Quote Link to comment https://forums.phpfreaks.com/topic/68048-fill-fields-when-user-selects-user-from-db/#findComment-342039 Share on other sites More sharing options...
eits Posted September 5, 2007 Author Share Posted September 5, 2007 I already have: <select name="select"> <?php do { ?> <option value="<?php echo $row_conn1['clientname']?>"> <?php echo $row_conn['clientname']?></option> <?php } while ($row_conn = mysql_fetch_assoc($conn)); $rows = mysql_num_rows($conn); if($rows < 10) { mysql_data_seek($conn, 0); $row_conn = mysql_fetch_assoc($conn); } ?> </select> to get data for the selectbox, now I just need some way of making the data in the other field I have to change when a user selects something from the selectbox. I know no javascript but am guessing the onchange is the way to go. Quote Link to comment https://forums.phpfreaks.com/topic/68048-fill-fields-when-user-selects-user-from-db/#findComment-342046 Share on other sites More sharing options...
eits Posted September 5, 2007 Author Share Posted September 5, 2007 Anybody???? Quote Link to comment https://forums.phpfreaks.com/topic/68048-fill-fields-when-user-selects-user-from-db/#findComment-342073 Share on other sites More sharing options...
eits Posted September 5, 2007 Author Share Posted September 5, 2007 *Bump* Quote Link to comment https://forums.phpfreaks.com/topic/68048-fill-fields-when-user-selects-user-from-db/#findComment-342174 Share on other sites More sharing options...
eits Posted September 5, 2007 Author Share Posted September 5, 2007 Come on somebody!!! lol help a man out! Quote Link to comment https://forums.phpfreaks.com/topic/68048-fill-fields-when-user-selects-user-from-db/#findComment-342267 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.