Javascript 在窗体外部的重定向按钮中使用窗体中的值

Javascript 在窗体外部的重定向按钮中使用窗体中的值,javascript,php,html,Javascript,Php,Html,从一个表单中的下拉列表中获取所选值,然后单击表单外的按钮将值发送到php页面 <div class="drpvendorname"> <font style="color: white;"> <label>Distribution Point:</label> </font> </div> <select class="form-control

从一个表单中的下拉列表中获取所选值,然后单击表单外的按钮将值发送到php页面

<div class="drpvendorname">
      <font style="color: white;">
        <label>Distribution Point:</label>        
    </font>
    </div>
        <select class="form-control" id="drpvendor" name="pointname" required="">
        <option selected disabled>Choose distribution point</option>
         <?php
          $strSQL = "SELECT * FROM point_tbl ORDER BY pointname ASC";
          $query = mysqli_query($db, $strSQL);
          while($result = mysqli_fetch_array($query))
          {          
            echo '<option onClick="distribution('.$result['pointshortname'].')" value="' .$result['pointshortname'].'">'. $result['pointname'].'</option>';
          }
          ?>
        </select>      
      </form><!--form1 ends here-->

      <form action="../customer/form.php"><!--form2 starts here-->
      <button class="btn pos7" name="abc" method="GET" style="margin-left:5%;">New Customer</button>
      </form><!--form2 ends here-->

      <div class="dailybreakupbtn">  
      <input class="btn" type="submit" id="dailybreakupbutn" name="dailybreakup" value="Enter Daily Breakup" onClick="distribution(<?=$pointname?>)"/>
      </div>
      <?php
      if(isset($pointname)){      
       ?>
      <script type="text/javascript">
        function distribution(pointname){
          var pointname;
          window.location.href="dailybreakup.php?query=" +pointname;
        }
      </script>
      <?php
      }
      ?>

分发点:
选择配送点

愿这对您有所帮助:) Html代码:

<form action= "" method= "post">
<select class="form-control drpvendor" id="drpvendor" name="pointname" required="">
        <option selected disabled>Choose distribution point</option>
         <?php
          $strSQL = "SELECT * FROM point_tbl ORDER BY pointname ASC";
          $query = mysqli_query($db, $strSQL);
          while($result = mysqli_fetch_array($query))
          {          
            echo '<option value="'.$result['pointshortname'].'">'. $result['pointname'].'</option>';
          }
          ?>
        </select> 
</form>

愿这对您有所帮助:) Html代码:

<form action= "" method= "post">
<select class="form-control drpvendor" id="drpvendor" name="pointname" required="">
        <option selected disabled>Choose distribution point</option>
         <?php
          $strSQL = "SELECT * FROM point_tbl ORDER BY pointname ASC";
          $query = mysqli_query($db, $strSQL);
          while($result = mysqli_fetch_array($query))
          {          
            echo '<option value="'.$result['pointshortname'].'">'. $result['pointname'].'</option>';
          }
          ?>
        </select> 
</form>
使用代码

    <script   src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> // please link the path or use cdn 
<script type="text/javascript">
function call_me(){
    var pointname=document.getElementById("drpvendor").value;
    alert(pointname); // comment it after testing 
    window.location.href="dailybreakup.php?query=" +pointname;
}
</script>
<form>
    <select class="form-control" id="drpvendor" name="pointname" required="">
    <option selected disabled>Choose distribution point</option>
     <?php
      $strSQL = "SELECT * FROM point_tbl ORDER BY pointname ASC";
      $query = mysqli_query($db, $strSQL);
      while($result = mysqli_fetch_array($query))
      {          
        echo '<option  value="' .$result['pointshortname'].'">'. $result['pointname'].'</option>';
      }
      ?>
    </select>  
   <input type="button" onclick="call_me()"/>       
  </form><!--form1 ends here-->

    Note : 1) Code is not tested 
           2) use your select id instead of your_select_id
           3)  check variable 
//请链接路径或使用cdn
函数调用_me(){
var pointname=document.getElementById(“drpvendor”).value;
警报(pointname);//测试后对其进行注释
window.location.href=“dailybreakup.php?query=“+pointname;
}
选择配送点
注:1)代码未经测试
2) 使用您的选择id而不是\u选择\u id
3) 检查变量
使用代码

    <script   src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> // please link the path or use cdn 
<script type="text/javascript">
function call_me(){
    var pointname=document.getElementById("drpvendor").value;
    alert(pointname); // comment it after testing 
    window.location.href="dailybreakup.php?query=" +pointname;
}
</script>
<form>
    <select class="form-control" id="drpvendor" name="pointname" required="">
    <option selected disabled>Choose distribution point</option>
     <?php
      $strSQL = "SELECT * FROM point_tbl ORDER BY pointname ASC";
      $query = mysqli_query($db, $strSQL);
      while($result = mysqli_fetch_array($query))
      {          
        echo '<option  value="' .$result['pointshortname'].'">'. $result['pointname'].'</option>';
      }
      ?>
    </select>  
   <input type="button" onclick="call_me()"/>       
  </form><!--form1 ends here-->

    Note : 1) Code is not tested 
           2) use your select id instead of your_select_id
           3)  check variable 
//请链接路径或使用cdn
函数调用_me(){
var pointname=document.getElementById(“drpvendor”).value;
警报(pointname);//测试后对其进行注释
window.location.href=“dailybreakup.php?query=“+pointname;
}
选择配送点
注:1)代码未经测试
2) 使用您的选择id而不是\u选择\u id
3) 检查变量


是否有人可以帮助我将所选值发送到下一页,而无需将按钮放在标签中使用ajax代码创建一个关于选择和发送数据的onchange函数button id是Daily Breakup Burthink CarthikeyanVivekanandhan和Gulshan如何做到这一点我是ajax新手有人可以帮助我将所选值发送到下一页吗如果不将按钮放在Tag表单中,使用ajax代码在选择和发送数据时创建一个onchange函数button id是Daily BreakupbuntnkarthikeyanVivekanandhan和Gulshan如何做到这一点我对ajax调用不熟悉这里我将如何获得下拉框值…?请帮助我,我不知道在哪里放置选择框id或名称和按钮id或name?@Avinash用此行替换您的select html现在不需要按钮。只需将您的select放入表单并删除formonChange=dailybreakup的操作(this.value)这里我将如何获得下拉框值…?请帮助我,我不知道将选择框id或名称以及按钮id或名称放在哪里?@Avinash用此行替换您的选择html现在不需要按钮。只需将您的选择放在表单中并删除formonChange=dailybreakup(this.value)的操作即可我已经寄给你了,我已经寄给你了。