I want to fetch the dropdown value based on an another input value and also i create the dropdown dynmaically using add button. how can i get the value appropriate.
Select rack name -> want to fetch the droplist of rack series using add button i must want to create many fields like this
Thanks in Advance, Please anybody give the solution for this.
function get_rack_series() {
var rack = document.getElementsByClassName('rack');
for (i = 0; i < rack.length; i++) {
$.post(base_url+'suggest/get_rack_series',
{
rack_name:rack[i].value
},
function(res){
$('.rs').html(res);
}
);
}
}
This for add function
$(function() {
var addDiv = $('#addinput');
var i = $('#addinput p').size() + 1;
$('#addNew').live('click', function() {
$('<p><select name="rack[]" id="rack'+i+'" class="rack select_small caps_txt validate[required]" onchange="get_rack_series();"><option value="">select</option><?php if(isset($get_rack_name)){foreach($get_rack_name as $rck){?> <option value="<?php echo $rck['rack_name'];?>"><?php echo $rck['rack_name'];?></option><?php }}?></select> <span id="rs" class="rs"></span> <input type="text" id="partnumber_' + i +'" name="partnumber[]" type="text" class="input4 validate[required] caps_txt" onblur="get_exists_status();"/><a href="#" id="remNew">Remove</a> </p>').appendTo(addDiv);
i++;
return false;
});
$('#remNew').live('click', function() {
if( i > 1 ) {
$(this).parents('p').remove();
i--;
}
return false;
});
});
html code
<td width="263">
<div id="addinput">
<p>
<select name="rack_name[]" id="rack_name1" class="rack select_small caps_txt validate[required]" onchange="get_rack_series();">
<option value="">select</option>
<?php
if(isset($get_rack_name)) {
foreach($get_rack_name as $rck)
{?>
<option value="<?php echo $rck['rack_name'];?>"><?php echo $rck['rack_name'];?></option>
<?php
}
}
?>
</select>
<span id="rs" class="rs"></span>
<input name="partnumber[]" type="text" class="input4 validate[required] caps_txt" id="partnumber" onblur="get_exists_status();" />
</p>
</div>
</td>
I would say echo
all your options and add classes to them of the rack name, then hide and show them onchange
.
Trying to hide some options tag with jquery doesn't work IE, Safari and Opera
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.