javascript - Building dependent dropdown with Ajax and Jquery: having trouble getting 2 php GET variables to show up on get_state.php - ajax is sending too -


i have index.php?workorder_base_id=w21592 -> getting work order number entered, searches mssql database. call $_get['workorder_base_id']; used run other queries database results.

i need dependent drop down. first drop down runs query , returns result , uses ajax go get_state.php. there it's showing undefined varialbe/index when try call $_get['workorder_base_id']; run 2nd query , output in second dropdown. how can around this?

<?php  require_once("dbcontroller.php");  $db_handle = new dbcontroller();  $query ="select distinct r.part_id partid, r.part_id  +  '  (' +p.description + ')'  partfull  		from requirement r inner join part p   		on r.part_id = p.id  		where not exists (select part_id trace_profile tp r.part_id=tp.part_id)   		and  (r.workorder_base_id = '".$_get["workorder_base_id"]."')";  $results = $db_handle->runquery($query);  ?>  <html>  <head>  <title>jquery dependent dropdown list - countries , states</title>  <head>  <style>  body{width:610px;}  .frmdronpdown {border: 1px solid #f0f0f0;background-color:#c8eefd;margin: 2px 0px;padding:40px;}  .demoinputbox {padding: 10px;border: #f0f0f0 1px solid;border-radius: 4px;background-color: #fff;width: 50%;}  .row{padding-bottom:15px;}  </style>  <script src="https://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript"></script>  <script>  function getstate(val) {  	$.ajax({  	type: "get",  	url: "index.php",  	data:'partfull='+val,  	success: function(data){  		$("#state-list").html(data);  	}  	});  }    function selectcountry(val) {  $("#search-box").val(val);  $("#suggesstion-box").hide();  }  </script>  </head>  <body>  <?   ini_set('display_errors',1);  error_reporting(e_all);  date_default_timezone_set('america/new_york');  $dateunix = new datetime();  $dateunix = $dateunix->gettimestamp();  ?>  <input type="textarea" name="workorder_base_id" rows="3" cols="5" id="workorder_base_id" value="<?= $_get["workorder_base_id"];?>" data-theme="f" class="ui-input-text ui-body-f ui-corner-all ui-shadow-inset"   required>  			<input method="get" id="button"   type="submit">  <h5>work order id:</h5><labelh5><center><? echo $_get["workorder_base_id"];?></center></labelh5>   <div class="frmdronpdown">  <div class="row">  <label>partid:</label><br/>  <select name="partfull" id="partfull-list" class="demoinputbox" onchange="getstate(this.value);">  <option value="">select part id:</option>  <?php  foreach($results $country) {  ?>  <option value="<?php echo $country["partid"]; ?>"><?php echo $country["partfull"]; ?> </option>  <?php  }  ?>  </select>  </div>  <div class="row">  <label>op seq no:</label><br/>  <select name="state" id="state-list" class="demoinputbox">  <option value="">select operation seq. no</option>  </select>    </div>  </div>      </body>  </html>

get_state.php

	   <!doctype html>  <html>  <head>  <meta name="viewport" content="height=device-height, width=device-width, initial-scale=1.0, user-scalable=no" />        <title>get state </title>                  <!-- jquery  -->        <link href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet">  	<link rel="stylesheet" type="text/css" href="style.css" />      <script src="//code.jquery.com/jquery-1.10.2.js"></script>      <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>      <!-- jquery  -->                    </head>                  <body>  	 <input name="workorder_base_id" type="hidden" value="<?= $_get["workorder_base_id"];?>" />    <?php  ini_set('display_errors',1);  error_reporting(e_all);  date_default_timezone_set('america/new_york');  $dateunix = new datetime();  $dateunix = $dateunix->gettimestamp();    require_once("dbcontroller.php");  $db_handle = new dbcontroller();  if($_get["partfull"] != "") {     	  	 echo $wobi;  	 echo $_get['partfull'];  	  	 echo $_get['workorder_base_id'];  	  	$query ="select distinct r.operation_seq_no osn, '(' + convert(varchar(30), r.operation_seq_no) + ')  ' + o.resource_id expr1  operation   o   inner join requirement r   on r.operation_seq_no = o.sequence_no , o.workorder_base_id = r.workorder_base_id     (r.workorder_base_id =  '".$_get['workorder_base_id']."') , (r.part_id = '" . $_get["partfull"] . "')";        	  	  	$results = $db_handle->runquery($query);  ?>  	<option value="">select operation seq. no 2</option>  <?php  	foreach($results $state) {  ?>  	<option value="<?php echo $state["osn"]; ?>"><?php echo $state["expr1"]; ?></option>  <?php  	}  }      ?>  </body>  </html>


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -