Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a button, if i click that button how can I send variable through url? Is there anyway to do that? please anyone help me

HTML
<button type="button" class="btn btn-primary btn-sm" id="send" onClick="add('<?php echo $page_owner; ?>','add_user');"">Send</button>


how to send onclick variable through url?
Posted

You send values typically through GET and POST.
If you want to send through URL, use GET - http://www.w3schools.com/jquery/jquery_ajax_get_post.asp[^].
 
Share this answer
 
PHP
$("button").click(function(){
    $.get("demo_test.asp", function(data, status){
        alert("Data: " + data + "\nStatus: " + status);
    });
});
 
Share this answer
 
Comments
Member 11406049 17-Mar-15 2:46am    
I have totally six buttons, for each button I have specific function() which need to perform required operations in javascript file. can I replace .asp file to .js file? and I need to perform above script for all 6 buttons individually?
[no name] 17-Mar-15 2:52am    
You have to perform script individually.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900