从下拉式onchange重定向中获取价值 [英] get value from drop down onchange redirect

查看:54
本文介绍了从下拉式onchange重定向中获取价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从下拉onchange重定向中获得了一个值,当我选择值之一时,在重定向时我没有从下拉onchange重定向中更改值.我的javascript

i have from drop down onchange redirect, when i select one of value, page when i redirect not changet value from drop down onchange redirct. my javascript

<script language="JavaScript" type="text/javascript">
                    function redirect(site){
                        window.location= site
                    }
                </script>

在我这样的表单上

<select name="bulan" onchange="redirect(this.value)">
                    <option value="#">Pilih Bulan</option>
                    <option value="<?= base_url(); ?>index.php/kalender/cari_agenda/<?= $this->uri->segment(3); ?>/01">Januari</option>
                    <option value="<?= base_url(); ?>index.php/kalender/cari_agenda/<?= $this->uri->segment(3); ?>/02">Februari</option>
                    <option value="<?= base_url(); ?>index.php/kalender/cari_agenda/<?= $this->uri->segment(3); ?>/03">Maret</option>
                    <option value="<?= base_url(); ?>index.php/kalender/cari_agenda/<?= $this->uri->segment(3); ?>/04">April</option>
                    <option value="<?= base_url(); ?>index.php/kalender/cari_agenda/<?= $this->uri->segment(3); ?>/05">Mei</option>
                    <option value="<?= base_url(); ?>index.php/kalender/cari_agenda/<?= $this->uri->segment(3); ?>/06">Juni</option>
                    <option value="<?= base_url(); ?>index.php/kalender/cari_agenda/<?= $this->uri->segment(3); ?>/07">Juli</option>
                    <option value="<?= base_url(); ?>index.php/kalender/cari_agenda/<?= $this->uri->segment(3); ?>/08">Agustus</option>
                    <option value="<?= base_url(); ?>index.php/kalender/cari_agenda/<?= $this->uri->segment(3); ?>/09">September</option>
                    <option value="<?= base_url(); ?>index.php/kalender/cari_agenda/<?= $this->uri->segment(3); ?>/10">Oktober</option>
                    <option value="<?= base_url(); ?>index.php/kalender/cari_agenda/<?= $this->uri->segment(3); ?>/11">November</option>
                    <option value="<?= base_url(); ?>index.php/kalender/cari_agenda/<?= $this->uri->segment(3); ?>/12">Desember</option>
                </select>

我如何从此表单中获取选择的值?

how i get the value selected from this form ??

推荐答案

您编写的脚本可以正常工作.我可以假设页面上的URL或其他js代码有问题.如果您使用的是不带协议的网址(例如http://),则可能会导致重定向问题.

The script that you written works just fine. I can assume that it is something wrong with URL or other js code on the page. If you are using URL without protocol (e.g. http://) then it may cause the problem for redirection.

如果要获得类别,请在注释中指出.然后我建议这样做:

If you want get a category, as you pointed it in your comment. Then I suggest this:

<script type="text/javascript">
function redirect(site){
    var category = site.split('/')[5];
    //other code goes here...
}
</script>

这篇关于从下拉式onchange重定向中获取价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆