doubi4435 2015-03-23 10:54
浏览 14

html select语句与js和php无法正常工作

I am trying to to use html select and basing on the selected value display the mysql query value. I pick the selected value by id using javascript and their after convert them to php variables as demostrated below

I then use a comparison statement to evaluate the php variable and if true go ahead echo the db query result. However the if statement on the php script seems not to be working and doesnt return or echo anything

        //HTML FORM select
    <form method="post" action="" name="myform">
          <th style="width:3%;" >MOH
            <select name="moh" id="myselect" onchange="javascript: form.submit();">        
              <option id="4" value="received_moh_day1">Day 1</option>
              <option id="5" value= "received_moh_day2">Day 2</option>
              <option id="6" value= "received_moh_day1_and_2">Day 1 and 2</option>
            </select> 
          </th>
        </form>
          <script type="text/javascript">

            var jvalue_moh_1 = document.getElementById('4').value;
            var jvalue_moh_2 = document.getElementById('5').value;
            var jvalue_moh_3 = document.getElementById('6').value;
            //document.getElementById('personlist').value=Person_ID;         
          </script>

         <script type="text/javascript">   
         //Convert Javascript variable to php variable             
           <?php 

           $moh1 = "<script>document.write(jvalue_moh_1)</script>";
           $moh2 = "<script>document.write(jvalue_moh_2)</script>";
           $moh3 = "<script>document.write(jvalue_moh_3)</script>";
           //$moh = "<script>document.write(jvalue2)</script>" ;
           ?>   
         </script>        

        </tr>
      </thead>
      <tbody>
      <?php endif; ?>
        <?php 


        $i=1;
            if ($data && $_GET['log'] == 'ATTNSC')  {
              print_r($moe1);
              foreach ($data as $key => $value) {

                  //print_r($moe3);
                  if($moe3 == 'received_moe_day1_and_2'){ 
                   echo "<td class='align-td' id='received_moe_day1_and_2_td".$i."'>".$value['received_moe_day1_and_2']."</td>";
                   }
                  elseif ($moe2 == 'received_moe_day2'){

                   echo "<td class='align-td' id='received_moe_day1_and_2_td".$i."'>".$value['received_moe_day2']."</td>";
                   }
                  elseif ($moe1 == 'received_moe_day1'){
                    echo "<td class='align-td' id='received_moe_day1_td".$i."'>".$value['received_moe_day1']."</td>";
                  }

                  elseif ($moh3 == 'received_moh_day1_and_2'){    
                   echo "<td class='align-td' id='received_moh_day1_and_2_td".$i."'>".$value['received_moh_day1_and_2']."</td>";
                   }
                  elseif ($moh2 == 'received_moh_day2'){

                   echo "<td class='align-td' id='received_moh_day1_and_2_td".$i."'>".$value['received_moh_day2']."</td>";
                   }
                  elseif ($moh1 == 'received_moh_day1') {
                    echo "<td class='align-td' id='received_moh_day1_td".$i."'>".$value['received_moh_day1']."</td>";

                  }



                $i++;
              }
            }else{

        ?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥16 mybatis的代理对象无法通过@Autowired装填
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂
    • ¥15 wordpress 产品图片 GIF 没法显示
    • ¥15 求三国群英传pl国战时间的修改方法
    • ¥15 matlab代码代写,需写出详细代码,代价私
    • ¥15 ROS系统搭建请教(跨境电商用途)