[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 140
  • Last Modified:

How to Pass JS variable to the Action page as a $_POST with submit()

I want JS to:

1) Read the value of Form text field elements
2) Pass the values to the Action page upon a JS submit() using $_POST (not in the URL).
3) Initiate the submit with a button (not a submit) Form element

I'm stumped...
0
Ron1959
Asked:
Ron1959
  • 3
  • 3
1 Solution
 
EyalCommented:
jquery is your solution :)

see http://api.jquery.com/jQuery.ajax/
0
 
Kim WalkerWeb Programmer/TechnicianCommented:
Sounds like you just need the image to submit the form.

<img id="button" src="/images/button.jpg" onmouseup="javascript: document.forms[0].submit();">

Open in new window

0
 
Ron1959Author Commented:
I spent some time looking at jquery.  You might be right, but it's going to have more learning curve that I have time for right now.

I will look into it later, though.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
EyalCommented:
OK... will help you little bit more :)

1) Read the value of Form text field elements
get: $('#controlid').val()
set: $('#controlid').val(newvalue)
2) Pass the values to the Action page upon a JS submit() using $_POST (not in the URL).
$.ajax({
   type: "POST",
   url: "some.php",
   data: "name=John&location=Boston",
   success: function(msg){
     alert( "Data Saved: " + msg );
   }
 });
3) Initiate the submit with a button (not a submit) Form element
 $('#buttonid').click(function(){
do the ajax call here :)
}
);
0
 
Ron1959Author Commented:
In

   type: "POST",
   url: "some.php",

Are "type:" and "url:" part of the code or just your annotation?

Should I be able to

var $somevariable = $('#controlid').val();


0
 
EyalCommented:
in your post you told us that you want a post so this is what I wrote in my response
url change it to whatever fits your demands
and..
var $somevariable = $('#controlid').val();
is ok
0
 
Ron1959Author Commented:
Side tracked....  Will be back to this soon.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now