fareedreg Posted January 14, 2010 Share Posted January 14, 2010 how to put text in combo box at run time... <select name="cmbsuppid" id="cmbissueid" onchange="showSupplier(this.value)";> <?php include('connect.php'); $Tb = "booksupp_master"; mysql_select_db($Db, $link); $query = "select supp_id from $Tb order by supp_id"; $result= mysql_query($query,$link); $fel=mysql_num_fields($result); $nro=mysql_num_rows($result); if ($nro>0) { echo "<option>-- Select Supplier --</option>\n"; while ($row=mysql_fetch_array($result)) { echo "<option value='$row[supp_id]'>$row[supp_id]</option>\n"; } } mysql_close($link); ?> above is my code i m picking up value from mysql.. but how can i put text in it. or how can i move combobox at run time ?? Quote Link to comment https://forums.phpfreaks.com/topic/188429-how-to-put-value-into-comobox/ Share on other sites More sharing options...
PravinS Posted January 14, 2010 Share Posted January 14, 2010 Replace the while loop while ($row=mysql_fetch_array($result)) { echo '<option value="'.$row['supp_id'].'">'.$row['supp_id'].'</option>\n'; } Quote Link to comment https://forums.phpfreaks.com/topic/188429-how-to-put-value-into-comobox/#findComment-994726 Share on other sites More sharing options...
fareedreg Posted January 14, 2010 Author Share Posted January 14, 2010 YEAH i m using php ajax mysql From where you are picking up the data. It is in php/mysql or using AJAX to fetch the data? Quote Link to comment https://forums.phpfreaks.com/topic/188429-how-to-put-value-into-comobox/#findComment-994729 Share on other sites More sharing options...
PravinS Posted January 14, 2010 Share Posted January 14, 2010 Also if you want to display any other text from table then you need to add field name in query and you drop down will be like this. while ($row=mysql_fetch_array($result)) { echo '<option value="'.$row['supp_id'].'">'.$row['TXTFIELD'].'</option>\n'; } check the TXTFIELD in drop down, just replace your field name there Quote Link to comment https://forums.phpfreaks.com/topic/188429-how-to-put-value-into-comobox/#findComment-994732 Share on other sites More sharing options...
fareedreg Posted January 14, 2010 Author Share Posted January 14, 2010 not working dear Actually what i want to do is that... I am having modification form .. in which i m displaying value of previous selected supplier. I also want to fill this option box with all supplier ids ,, so in case if user selected wrong supplier id in addform , he/she can modify it in modification form. Also if you want to display any other text from table then you need to add field name in query and you drop down will be like this. while ($row=mysql_fetch_array($result)) { echo '<option value="'.$row['supp_id'].'">'.$row['TXTFIELD'].'</option>\n'; } check the TXTFIELD in drop down, just replace your field name there Quote Link to comment https://forums.phpfreaks.com/topic/188429-how-to-put-value-into-comobox/#findComment-994735 Share on other sites More sharing options...
PravinS Posted January 14, 2010 Share Posted January 14, 2010 You mean to add text box to edit in combo box? Quote Link to comment https://forums.phpfreaks.com/topic/188429-how-to-put-value-into-comobox/#findComment-994743 Share on other sites More sharing options...
fareedreg Posted January 14, 2010 Author Share Posted January 14, 2010 yes ... first display related supp id then ... editiing if user want You mean to add text box to edit in combo box? Quote Link to comment https://forums.phpfreaks.com/topic/188429-how-to-put-value-into-comobox/#findComment-994812 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.