dqyat62284 2019-08-05 09:30 采纳率: 0%
浏览 38
已采纳

如何选择选项时如何更改为URL

how can i take link in select and redirect same page but on specific option value this is my code...

<select class="form-control required" id="institute" name="institute">
    <option value="0">Select Institute</option>
    <?php
    if(!empty($institute))
    {
        foreach ($institute as $in)
        {
            ?>
            <option value="<?php echo $in->institute_id ?>"><?php echo $in->institute_name ?>-<?php echo $in->insti_sortname ?></option>
            <?php
        }
    }
    ?>
    <option value="<?php echo base_url() ?>college/addinstitute">Other</option>
</select>

in last option there is link only that option is change none other

enter image description here

  • 写回答

1条回答 默认 最新

  • dqoqnmb163241 2019-08-05 09:46
    关注

    Solved By jQuery

    $(document).on('change', '#institute', function() {
    var current_val = $( "select option:selected" ).text();
    
    if(current_val=='Other'){
    //Do Nothing....
    }else {
    window.location.replace("https://google.com");
    }
    
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?