here is the jQuery code $(document).ready(function(){ var root = window.location.toString(); $("#lwdigetup").live('click', function(){ var t = "<?php echo time() ?>"; $("#sid").val('').val("<?php echo time() ?>"); console.log(t); }); }); Code (markup): #sid is an input. Everytime I link on #lwidgetup, which is a link, I get exactly same value. And console is the same. Any ideas ?
Because the time is added in PHP. Which will stay static until you refresh the page. Try getting the code via JS: $(document).ready(function(){ var root = window.location.toString(); $("#lwdigetup").live('click', function(){ var currentDate = new Date() var time = currentDate.getTime(); var t = time; $("#sid").val(time); console.log(time); }); }); Code (markup):
time won't change when you click the button n amount of times, cause php has already shown you the value when the page has finished loading. Use ajax if you want time to be updated.
And this messed my entire day. not is obvious. I am kinda tired...need some sleep. I can't believe I posted that. I was thinking at $.get("something.php") ...