duanhuren5581 2014-03-12 14:58
浏览 42
已采纳

多个下拉列表中的多个值

Hello i'm working on some project and i have 6 dropdowns and every has it values

Example in first dropdown i have:

<input type="checkbox" id="dt1" name="dt1" value="1">20 kW<br> 
<input type="checkbox" id="dt2" name="dt2" value="2">40 kW <br> 
<input type="checkbox" id="dt3" name="dt3" value="3">60 kW <br> 

And in Other i have:

<input type="checkbox" id="stv1" name="stv1" value="6">500 L<br> 
<input type="checkbox" id="stv2" name="stv2" value="7">1000 L<br> 
<input type="checkbox" id="stv3" name="stv3" value="8">"2000 L<br> 

But now i have many questions first how can i make drop down with only one selection? second question is how can i give result when someone choose from drop down one value 1 and from drop down 2 value 8 how can i make value1+value8=link?

Till now i have used

if (containsOnly(values, ['1', '8'])) {
        alert('something');
    }

but now i dont need alert, i need link so if someone can help me or do something on JS Fiddle that would be great

my latest work on this topic was this http://jsfiddle.net/KyleMuir/bUdra/5/ but now its not just choice a b or c, it must be choice a drop down with 3 or 4 choices and without alert.. If someone could help me it would be great

  • 写回答

1条回答 默认 最新

  • dongpo2340 2014-03-12 15:19
    关注

    with this code you can get both values in the same file or in an other file just edit it to what you need:

    <?php
        if($_POST) {
        $dd1 = $_POST['dropdown1'];
        $dd2 = $_POST['dropdown2'];
    
    header('Location: file.php?dd1='.$dd1.'&dd2='.$dd2);
    exit();
    }
    ?>
    
    <form action="" method="post">
        <select name="dropdown1">
            <option value="20">20 kW</option> 
            <option value="40">40 kW</option> 
            <option value="60">60 kW</option>
        </select>
    
        <select name="dropdown2">
            <option value="500">500 L</option> 
            <option value="1000">1000 L</option> 
            <option value="2000">2000 L</option>
        </select>
        <input type="submit" value="Calculate">
    </form>
    

    file.php could then be something like:

    <?php
    $dd1 = strip_tags($_GET['dd1']);
    $dd2 = strip_tags($_GET['dd2']);
    
    echo $dd1; //should give you the value from dropdown1
    echo $dd2; //should give yout the value from dropdown2
    ?>
    
    <!-- the php variables can also be used in javascript -->
    <!-- don't know for sure if this is the correct way to use php in javascript but atleast should be something like this -->
    <script type="text/javascript">
    var dropdown1 = <?php $dd1; ?>;
    var dropdown2 = <?php $dd2; ?>;
    </script>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动