Hvis jeg forstår det rigtigt, er dette én ting, du kan gøre:
PHP
<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['retail_slug']."\" value=\"".$row_retailers['retailer_id']."\"".$selected.">".$row_retailers['title']."</option>";
}
?>
</select>
<input type="hidden" name="retailer_slug"/>
jQuery
$('#retailer_id').on('change', function() {
var $selected = $('#retailer_id option:selected');
$('input[name=retailer_slug]').val($selected.data('slug'));
});
Så grundlæggende er ideen her, at du gemmer retailer_slug
værdi som en data-
attribut på hver