Hi all,
I have some very rudimentary HTML markup w/ serverside PHP that
populates a select box like this:
<select name="make" id="make" onchange="if ((this.value) ==
'add_make') { $('#addMakeOption').show(); } else { $
('#addMakeOption').hide(); }" >
<option clas="staticOpt">**********</option>
<option value="add_make" class="staticOpt">Add Make</option>
<?php foreach($makes->result() as $make): ?>
<option value="<?= strtolower($make->name) ?>"> <?=
$make->name; ?
> </option>
<?php endforeach; ?>
</select> <br>
As you can see, I've added some jquery to pop up a div to let me add
more makes into the select box. I got that part working great with the
following code:
$('#add_make').click(function () {
//alert("Model value : " + $('#add_make_text').val());
$.ajax({
data: "make_val="+$('#add_make_text').val(),
timeout: 10000,
type: 'POST',
url: "/addvehicle/add_make",
error: function() { alert("Make was not
successfully
added. Contact the system administrator."); },
success: function() {
$('#addMakeOption').hide();
} // end success callback
}); // end $.ajax
}); // end add_make.click and stuff.
My only issue at this point is if I'm already using AJAX to populate a
select box, does anyone see a possible alternative here for me to re-
populate the select box in the success callback function? As this
point the only way I see doing that is with a full page refresh
otherwise.
Thanks for any advice.
- sf