deib97 Posted January 19, 2016 Share Posted January 19, 2016 Hello, i have source code like this : <script type="text/javascript"> var rowNum = 0; function addRow(frm) { rowNum ++; var row = '<p id="rowNum'+rowNum+'">Item name: <input type="text" name="name[]" value="'+frm.add_name.value+'"> Satuan: <input type="text" size="5" name="satuan[]" value="'+frm.add_satuan.value+'"> Item quantity: <input type="text" name="qty[]" size="20" value="'+frm.add_qty.value+'"> <input type="button" value="Remove" onclick="removeRow('+rowNum+');"></p>'; jQuery('#itemRows').append(row); frm.add_qty.value = ''; frm.add_name.value = ''; frm.add_satuan.value = ''; } function removeRow(rnum) { jQuery('#rowNum'+rnum).remove(); } </script> This code, for make dynamic row when add operation. Then, item name is input text. How change this input : <select name="group" class='arial11' id="group"> <?php $qdepart = mysql_query("select * from pemakai_group order by group_name asc"); if($qdepart != null){ while($ddepart = mysql_fetch_array($qdepart)){ $no++; if( $data[id_group] == $ddepart[id_group] ){ $seldepart[$no] = "selected";} echo "<option value=\"$ddepart[id_group]\" $seldepart[$no]>$ddepart[group_name]</option>"; } } ?> </select> Quote Link to comment https://forums.phpfreaks.com/topic/300532-how-to-insert-select-option-value-into-javascript/ 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.