我有Jquery的这段代码,我刚刚开始使用Jquery,但我对Javascript有一些了解。
<script>
$(document).ready(function(){
$("#d_or_t").val('navbar');//<?php echo "cms18"; ?>
// if ('<?php $key ?>'== '<?php ?>') {};
});
$('#selector').on('change',function(){
//alert($(this).find("option:selected").html()) ;
var data = document.getElementById('url_option');
var current = $(this).find("option:selected").html();
alert(current);
//alert(current);
//(data.dataset.domains);
});
</script>
我的HTML选择框是这个我有三个,我希望当我更改URL选择框时,另外2个选择框更改为数据
<form action="php-json.php" id="form" method="post">
<select name="selector" id="selector" class="form-control">
<!-- opzoeken wat de colon : betekend daar -->
<?php foreach ($aUrls as $key => $value)
: ?>
<option id="url_option" data-domains="<?php echo $aDomains[$key]; ?>" data-template="<?php echo $aTemplates[$key]; ?>" value="<?php echo $value; ?>">
<?php echo $value;?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="col-xs-12 col-md-3 col-lg-3">
<select name="d_or_t" id="d_or_t" class="form-control">
<?php foreach ($aDomains as $key => $value) : ?>
<option value="<?php echo $value; ?>"><?php echo $value; ?></option><?php endforeach; ?>
</select>
</div>
<div class="col-xs-12 col-md-3 col-lg-3">
<select name="t_or_t" id="d_or_t" class="form-control">
<?php foreach ($aTemplates as $key => $value) : ?>
<option value="<?php echo $value; ?>"><?php echo $value;?></option><?php endforeach; ?>
</select>
</div>
<div class="col-xs-12 col-md-3 col-lg-3">
<button type="submit" class="btn btn-default" value="veranderen">Veranderen</button>
</div>
</div>
</form>