user1559811
user1559811

Reputation: 449

make a javascript variable into php variable without refreshing page

with the code I have I can echo:<a id='test'> and it displays what was typed, however I need to make<a id='test'> into a variable so I can use it for mysql query's etc. is this possible at all?

<script type="text/javascript">

   function email(){
   var input = document.getElementById('input').value;
   document.getElementById('text').innerHTML = input;
 }
</script>

<html>
  <p><input type='text' id='input' value='' />
    <input type='button' onclick='email()' value='submit'/></p>
</html>

<?php
    $info="<a id='text'>"//make this a variable;
    echo $info;
?>

Upvotes: 0

Views: 3206

Answers (1)

Roy
Roy

Reputation: 987

using AJAX with jQuery will help you make a simple call to the server, without page reloading. Then you can send any variables to a PHP file that will store them in your database.

Upvotes: 2

Related Questions