Jump to content

How to insert select option value into javascript?


deib97

Recommended Posts

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>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.