javascript - Automatically post form with onclick event -
there page shows button , needs user action able event handlers.
the page handles of variables , processing values:
$returnstring .= '<form action="" method="post">'; $returnstring .= '<input type="hidden" name="cost" value='.$cost.' />'; $returnstring .= '<input type="hidden" name="page" value='.$pageid.' />'; $confirm_purchase = esc_attr(get_option('my_confirm_purchase')); $returnstring .= '<input type="submit" name="submit" value="purchase" onclick="return confirm(\''.$confirm_purchase.'\')" />'; $returnstring .= '</form>';
i need process form automatically. tried window.onload
, auto submit referring form id, did not work.
the page submitting form automatically , need change onclick
event automatically, too.
is there way can handle issue? how can change structure without using form ?
maybe use jquery , try this:
$('<form method="post"><input id="test" value="3"></form>').submit();
encapsulate $returnstring this:
$finalstring = "$(".$returnstring.").submit();"
this rendered javascript has executed after dom ready:
$(document).ready(function(){ //your code });
.submit() automatically submits html-form upon execution. test if works, used in older intranet applications , worked.
Comments
Post a Comment