samedi 14 mars 2015

get data-price of selected value in dropdown in a array


Vote count:

0




I have following code



<tbody>
<tr>
<td style="width:40%"> <select id="pname.0" name="pname[]" class="form-control ">
<?php
$this->db->order_by('name','asc');
$prod = $this->db->get('product')->result_array();
foreach($prod as $row): ?>
<option data-price="<?php echo $row['price'];?>" value="<?php echo $row['prod_id'];?>" >
<?php echo ucwords($row['name']);?>
</option>
<?php endforeach; ?>
</select></td>
<td style="width:10%"><input class="form-control" onchange="javascript:calc();" id="item_quantity.0" name="qnty[]" value=""/></td>
<td class="text-right" style="width:10%"><input class="form-control text-right" onchange="javascript:calc();" id="item_price.0" name="price[]" value=""/></td>

<td class="text-right" style="width:10%"><input class="form-control text-right" id="subtot.0" readonly name="item_sub_total" value=""/></td>
</tr>
</tbody>


Now i want to get the value of data-price attribute of selected option in Dropdown to the textbox having dynamic id item_price_0 This is changing as I have added the add row button. When I click on Add row, the id will become item_price_1.


Kindly help me how can I get these value using jquery or javascript



asked 23 secs ago







get data-price of selected value in dropdown in a array

Aucun commentaire:

Enregistrer un commentaire