Jump to content

jQuery, use imput text as variable?


godsent

Recommended Posts

I just started learning  JavaScript and jQuery.

 

For example here is how my form looks like so far.

 

    <input name="field1" type="text" id="field1">
    <input name="field2" type="text" id="field2">
    <input type="submit" name="Submit" value="Submit" class="attack">

 

And this is how my code looks:

 

<script type="text/javascript">
$(document).ready(function(){
   $(".attack").click(function(){
     var one = "this is one";
     var two = "this is two";
      $.post("test.php", { var1: "one, var2: two },
         function(data){
            alert("Data Loaded: " + data);
      });
   });
});
</script>

What I'm trying to do is get variables "one" and "two" directly from the text fields. Please help me if you know how. 

Link to comment
https://forums.phpfreaks.com/topic/158468-jquery-use-imput-text-as-variable/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.