Support » Plugins » Hacks » how value returned from jquery can be used as a php variable

  • hi there, Pls help. For the last two days I am unable to resolve this problem:
    Part -1 😐 I am trying to pick the value of the first column of the Table-1 &
    Part -2 😐 based on the selection and clicking a button on the basis of the
    | value in a textbox trying to show rest of the detail in the Table-2

    Part-1 : is working fine, but
    Part-2 : using jquery I am able to show the value in a text box. Now when I try to pick the value from the text box, the value returning is NULL. why?
    Below is my code :

    <?php include ("dbcon.php"); ?>
    
    <!DOCTYPE html>
     <html>
      <head>
        <title></title>
        <link rel="stylesheet" type="text/css" href="workstyle.css">
        <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
        <script>
          var a;
          function getdatafromddl(){
             a = document.getElementById("payflag").value;
             location.href="?a="+a;
          }
        </script>
    
        <script>
          $(document).ready(function() {
             var selectedRow;
             var record;
             $('tr').click(function () {
                $('tr').removeClass('selected');
                $(this).addClass('selected');
                selectedRow = $(this);
             });
    
             $('#viewbtn').click(function() {
                var td = $(selectedRow).children('td');
                alert(td[0].innerText);
                var id = td[0].innerText;
                $('#order').val(id);
             });
          });
        </script>
      </head>
    
      <body>
        <div align="center">
           <img src="images/menu.jpg" alt="" />
        </div>
        <div class="centr-div">
          <!---------------------------------------------------------- Row 1 [Start]-->
          <div class="f-col"> <label id="statdd">Show orders on basis of&nbsp;&nbsp;:&nbsp;&nbsp;</div>
          <div class="s-col">?>
    	<select id="payflag" onchange="getdatafromddl()" class="pay">
    	  <option value = "-1">---- Selection ----</option>
    	  <option value = "Paid" <?php if($_GET['a'] == 'Paid') echo "selected"; ?> >Paid</option>
    	  <option value = "Un-Paid" <?php if($_GET['a'] == 'Un-Paid') echo "selected"; ?> >Un-Paid</option>
    	</select>
          </div>
          <div class="l-col"><input type="text" id="order" name="txtorder" /></div>
    
          <!-- *********************   Table - 1   *************************************************  -->
          <?php
             if (isset($_GET['a'])) {
                 $val = $_GET['a'];
    	 }
    	if(!empty($val)){
    	  if ($val == 'Un-Paid')
    	  {
    	    $getrecs = "SELECT u.t_ordid, DATE_FORMAT(u.tord_dt,'%d-%m-%Y') as label_date, c.u_name, s.stat_desc  FROM utmp_orders as u join user_dtls as c on c.user_id=u.user_id join status as s on s.stat_cd=u.stat_cd WHERE u.pay_flag='N'";
    	    $retrv = mysqli_query($connection, $getrecs);
      	  }else if ($val == 'Paid') {
    		$getrecs = "SELECT u.t_ordid, DATE_FORMAT(u.tord_dt,'%d-%m-%Y') as label_date, c.u_name, s.stat_desc  FROM utmp_orders as u join user_dtls as c on c.user_id=u.user_id join status as s on s.stat_cd=u.stat_cd WHERE u.pay_flag='Y'";
    	 	$retrv = mysqli_query($connection, $getrecs);
    	  }
    	  else{ $retrv="";}
    	}
          ?>
          <table id='show-recs'>
             <thead>
              <tr>
                <th>Order No.</th>
                <th>Order Dt.</th>
                <th>Client Name</th>
                <th>Status</th>
              </tr>
            </thead>
    <?php
    	if (!empty($retrv)){
    	while($retrvarr = mysqli_fetch_assoc($retrv)){
    ?>
    	<tbody>
    		<tr>
    			<td><?php echo $retrvarr["t_ordid"] ?></td>
    			<td><?php echo $retrvarr["label_date"] ?></td>
    			<td><?php echo $retrvarr["u_name"] ?></td>
    			<td><?php echo $retrvarr["stat_desc"] ?></td>
    		</tr>
    	</tbody>
    <?php }} ?>
    				</table>
    				<div class="spc"></div>
    				<div align="center"><input type="submit" id="viewbtn" class="showViewbtn" value="View Selected Record" /></div>
    				<div class="spc"></div>
    		<!-- *********************   Table - 2   *************************************************  -->
    				<?php
    					if (isset($_POST['txtorder'])){
    $ono = $_POST["txtorder"];
    					}
    
    					//$ono = 2;
    					if(!empty($ono)){
    $selrec_query = "SELECT u.file_path, u.lbl_qty, u.lbl_prc, s.scat_name FROM utmp_orders as u join subcategory as s on s.scat_id = u.scat_id where u.t_ordid = {$ono}";
    $result = mysqli_query($connection, $selrec_query);
    					}
    				?>
    
    				<table id='show-sel-recs'>
    <thead>
    	<tr>
    		<th>Label Image</th>
    		<th>Qty</th>
    		<th>Price (&pound;)</th>
    		<th>Category</th>
    		<th>Payment Recd</th>
    	</tr>
    </thead>
    <?php
    	if (!empty($result)){
    	while($resultarr = mysqli_fetch_assoc($result)){
    ?>
    		<tbody>
    			<tr>
    				<td><img src="<?php echo $resultarr['file_path'] ?>" alt="" style="width:61px; height:54px" /></td>
    				<td><?php echo $resultarr["lbl_qty"] ?></td>
    				<td><?php echo $resultarr["lbl_prc"] ?></td>
    				<td><?php echo $resultarr["scat_name"] ?></td>
    				<td></td>
    			</tr>
    		</tbody>
    	<?php }} ?>
    				</table>
    
    			</div>
    	</body>
    </html>
    <?php //get_footer(); ?>

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘how value returned from jquery can be used as a php variable’ is closed to new replies.