godsent Posted May 17, 2009 Share Posted May 17, 2009 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 More sharing options...
Ken2k7 Posted May 17, 2009 Share Posted May 17, 2009 You're messing up the quotes. See here: { var1: "one, var2: two } You have a quote opened before "one", but you never closed it. It should look like this - { var1: "one", var2: "two" } Link to comment https://forums.phpfreaks.com/topic/158468-jquery-use-imput-text-as-variable/#findComment-835950 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.