我现在有一个需求,就是 input 能跟随着select选中的option变化显示或隐藏。我给option中的value赋了两个值,我的想法是一个值用来控制 input 的变化,另一个值 传递到后台数据库显示。我现在通过select的onchange 实现了对 input 的控制,但是通过mybatis传递值到数据库就出现了问题,它把value中的两个值全部传递到了数据库。来大佬给我讲解下value值传递的问题吧。

解决方案 »

  1.   

    来来来,大佬你告诉我,一个option中怎么定义俩个value,
      

  2.   


    我说定义了两个value了吗?我说的是给value赋了两个值而已  
    <option value="中国,1"></option>就这样
      

  3.   

    不知道这样满不满足你说的需求<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <script type="text/javascript">
    $(document).ready(function() {
    $("#select").change(function() {
    if ($("#show").is(":selected"))
    $("#text").show();
    if ($("#hidden").is(":selected"))
    $("#text").hide();
    });
    });
    </script>
    <body>
    <select id="select">
    <option id="show">show</option>
    <option id="hidden">hidden</option>
    </select>
    <input id="text" type="text" />
    </body>
    </html>