Wednesday, 15 September 2010

javascript - JQuery Dynamic Option Select Issue -



javascript - JQuery Dynamic Option Select Issue -

this continution of question

here code dynamic jquery alternative select generator.

first take country, didn't include code, homecoming countryid passed controller, regionid, cityid. works until generating cityid alternative select menu, while move areaid didn't work.

what missing , how can prepare ?

i can't able generate menu after 3rd sec one.

here html :

<div id='result' name="result"> <select id="name"> <option value="" disabled>please select above</option> </select> </div> <div id='resulta' name="resulta"> <select id="name"> <option value="" disabled>please select above</option> </select> </div> <div id='resultb' name="resultb"> <select id="name"> <option value="" disabled>please select above</option> </select>

here script :

<script> var ab = $.noconflict(); ab(document).ready(function() { ab(document).on("change", "#countryid", function() { var countryid = ab("#countryid").val(); ab.post("globalregiongenerator", { countryid: countryid }, function(data) { ab("#result").html(data); }); }); }); </script> <script> var ac = $.noconflict(); ac(document).ready(function() { ac(document).on("change", "#regionname", function() { var regionname = ac("#regionname").val(); ac.post("globalcitygenerator", { regionname: regionname }, function(data) { ac("#resulta").html(data); }); }); }); </script> <script> var advertisement = $.noconflict(); ad(document).ready(function() { ad(document).on("change", "#cityname", function() { var cityname = ad("#cityname").val(); ad.post("globalareagenerator", { cityname: cityname }, function(data) { ad("#resultb").html(data); }); }); }); </script>

and here server side :

public function globalregiongenerator() { $countryid = input::get('countryid'); $result = db::select("select * part countryid =$countryid"); echo "<select id='regionname' name='regionname'> <option value='' id=''>select area</option>"; foreach ($result $value) { echo "<option value=".$value->regionid.">".$value->regionname."</option>"; } echo "</select>"; } public function globalcitygenerator() { $regionid = input::get('regionname'); $result = db::select("select * city regionid =$regionid"); echo "<select id='cityname' name='cityname'> <option value='' id=''>select area</option>"; foreach ($result $value) { echo "<option value=".$value->cityid.">".$value->cityname."</option>"; } echo "</select>"; } public function globalareagenerator() { $cityid = input::get('cityname'); $result = db::select("select * area cityid =$cityid"); echo "<select id='cityname' name='cityname'> <option value='' id=''>select area</option>"; foreach ($result $value) { echo "<option value=".$value->cityid.">".$value->cityname."</option>"; } echo "</select>"; }

note :

uncaught typeerror: undefined not function

this error got in console

change

echo "<option value=".$value->cityid.">".$value->cityname."</option>";

to

echo "<option value='".$value->cityid."'>".$value->cityname."</option>";

same other echos. you're generating

<option value=united states>united states</option>

but needs be

<option value='united states'>united states</option>

update:

change them

echo "<option value=\"".$value->cityid."\">".$value->cityname."</option>";

javascript php jquery html laravel-4

No comments:

Post a Comment