0

hey..am having a doubt that,while using ajax in a page ,am not accesing button value while submiting the details.it is automaticalyy goin to the ajax attached page itself..i need to update the value to the database. can anyone having the reply???

3
Contributors
5
Replies
39
Views
4 Years
Discussion Span
Last Post by sruthisru
0

i need php code for that..whenever am submiting on button i need to 'update' the value to the database.
view.php

 <tr>
      <th><p>Amount</p></th>
      <td><?php echo $row[6];?></td>
    </tr>

    <tr >
      <th><p>Status</p></th>
      <td><p>



      <div id="poll"> 
  <p><input type="radio" name="col" value="Collected" onClick="getVote(this.value)" >
  Collected</p>
        <p><input type="radio" name="col" id="radio2" value="Postponed" checked="checked"/>
          Postponed</p>
        <p><input type="radio" name="col" id="radio3" value="Rejected" />
        Rejected</p>
     </div>  </p></td>

    </tr>

this is the main page.shownd radio button are attached with ajax.while selecting collected radio button the ajax attached page wil open into the row. code is

<p>Amount:
    <label for="textfield"></label>
  <input type="text" name="textfield" id="textfield">
  </p>
  <p>&nbsp;</p>
  <p>
   <input type="submit" name="button" id="button" value="Change">
  </p>
  <?php

Now..i need to update the textfield value to older amount value by clicking on the update button.and need to replace with the old amount value to the new amunt value in database. can u help me?? thank you in ADVNC

0

Hai;

Try this,

** in main page **

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<table>
 <tr>
      <th><p>Amount</p></th>
      <td><?php echo $row[6]=10;?></td>
    </tr>

    <tr >
      <th><p>Status</p></th>
      <td><p>



      <div id="poll"> 
  <p><input type="radio" name="col" value="Collected" class="pole_type">
  Collected</p>
        <p><input type="radio" name="col" id="radio2" value="Postponed" class="pole_type" checked="checked"/>
          Postponed</p>
        <p><input type="radio" name="col" id="radio3" value="Rejected" class="pole_type" />
        Rejected</p>
     </div>  </p></td>

    </tr>
</table>
<script type="text/javascript">
$(function() {
    $(".pole_type").click(function(){
        var val = $(this).val();
        var orderId = "<?php echo $yourOrderId = 1; ?>";
         $.ajax({
            url: "ajaxrequest.php",
            type: "POST",
            data: "poll="+val+"&orderId="+orderId+"&action=editpoll",
            success: function (data) {
                alert(data);
            }
        }); 
    });
});
</script>

In ajaxrequest.php

<?php
switch($_POST['action']) {
    case'editpoll':
        //here you can do your action
        echo "Update your db with OrderId:".$_POST['orderId']." and poll status:".$_POST['poll'];
    break;
}
?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.