How does onclick receive variables transmitted by js? Html: & lt; input & nbsp; type = "button" & nbsp; onClick = "window. location. href = 'Do. php? Action = '"& nbsp; value & nbsp ;=& nbsp;" export "& nbsp;/& onclick how to receive variables transmitted by js?
Html:
JS:
Script
$ (Function (){
Var glob_oplist = new Array ();
$ ("# Select2"). each (function (){
$ (This). children ("option"). each (function (){
Glob_oplist.push ($ (this). val ());
});
});
Dtitles = JSON. stringify (glob_oplist );
});
Script
I want to assign the value of dtitles obtained by JS as a parameter to the action and pass it to the DO. php page in GET mode. how can I write this JS value in the ONCLICK event?
------ Solution --------------------
Dtitles = JSON. stringify (glob_oplist );
Window. location. href = 'Do. php? Action = '+ dtitles;
------ Solution --------------------
$ (Function (){
$ ("# Btn_test"). attr ("onClick", "alert (1 )");
});
LZ can follow the above method to rewrite the onClick attribute value of the button when page loading is complete.
Add your parameters
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service