i have a select input that get options from database retailer_id, what i need it, when the admin select a retailer on this select input, i'll have a new one with the retailer_slug, and then, when the admin create or update, will sen to database the retailer_id and the retailer_slug on hidden input. my code is:
EDITED
<select class="textbox2" id="retailer_id" name="retailer_id">
<option value="">--- Please select store ---</option>
<?php
$sql_retailers = smart_mysql_query("SELECT * FROM cashbackengine_retailers WHERE status='active' ORDER BY title ASC");
while ($row_retailers = mysql_fetch_array($sql_retailers))
{
if ($retailer_id == $row_retailers['retailer_id']) $selected = " selected=\"selected\""; else $selected = "";
echo "<option data-slug=\"".$row_retailers['slug_title']."\" value=\"".$row_retailers['retailer_id']."\"".$selected.">".$row_retailers['title']."</option>";
}
?>
</select>
<input type="text" name="slug" id="slug" value=""/>
<script type="text/javascript">
$(document).ready(function() {
$('#retailer_id').on('change', function() {
var $selected = $('#retailer_id option:selected');
$('input[name=slug]').val($selected.data('slug'));
});
});
</script>
cashbackengine_retailers)?