using jquery variable in php -


i've got dynamic table filled recordset mysql. each row has it's own delete button (image) delete specific row. button has class="button".

i'm using jquery popup modal popup when delete button clicked. in jquery script i'm creating variable contains numeric value of first td cel of row has been clicked on. works perfectly.

what i'm trying accomplish use variable on same php page. here knowledge runs out. i've read examples ajax solution this, lack knowledge use these examples solution.

jquery code:

<script src="../javascript/jquery-1.8.2.js"></script> <script src="../javascript/jquery.reveal.js"></script> <script type="text/javascript">    $(document).ready(function() {       $('.button').click(function(e) { // button activate our modal          var value=$(this).closest('tr').children('td:first').text();          alert(value); // works          $('#modal').reveal({ // item opened reveal             animation: 'fade', // fade, fadeandpop, none             animationspeed: 500, // how fast animtions             closeonbackgroundclick: false, // if click background modal close?             dismissmodalclass: 'close' // class of button or element close open modal          });       return false;       });    }); </script> 

i've been trying don't see logic anymore. hope can me this.

the issue javascript runs in client -- user's web browser -- while php runs on server. it's two-stage process: first, php executed on server , html rendered, sent client (the browser). then, client executes javascript on page.

you need way communicate js variable (value) server if want able use in php code. ajax 1 such way, helpful have more information on how want use information in php.

edit: based on comments above, should work. you'll have give yes button id attribute (here i'm assuming id yesbutton).

$(.button).click(function() {     var value=$(this).closest('tr').children('td:first').text();     $("#yesbutton").attr("href", "delete_verlof.php?id=" + value);     $('#modal').reveal({ // item opened reveal         animation: 'fade', // fade, fadeandpop, none         animationspeed: 500, // how fast animtions         closeonbackgroundclick: false, // if click background modal close?         dismissmodalclass: 'close' // class of button or element close open modal     });     return false; }); 

the important thing note js variable does not exist yet @ time @ php executes, not available php. i've done here instead dynamically change href of yes button whenever user clicks td, should have desired effect.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -