mock5c
asked on
Submit to hidden form.
Here's some example code that I found. I would like some assistance in understanding this code.
In the js file, there is this definition:
$(function(){
var win = window.open('', "mywindow");
var myform = $("#myform");
myform.find("#myattribute" ).val("X") ;
myform.attr("target", "mywindow");
myform.submit();
});
Then in the form_one.html , there is code this code (in addition to a another form block between <form> tags with a submit button tied to it):
<form style="display: none;" id="myform" action="myprog.cgi?page=/m ypage/inde x.html">
<input id="myattribute" name="myattribute" />
<input type="submit">
</form>
Can you please walk me through these lines? Does the js load when the is first loaded and will it post variables to a hidden form right away? If so, how is the hidden form displayed?
In the js file, there is this definition:
$(function(){
var win = window.open('', "mywindow");
var myform = $("#myform");
myform.find("#myattribute"
myform.attr("target", "mywindow");
myform.submit();
});
Then in the form_one.html , there is code this code (in addition to a another form block between <form> tags with a submit button tied to it):
<form style="display: none;" id="myform" action="myprog.cgi?page=/m
<input id="myattribute" name="myattribute" />
<input type="submit">
</form>
Can you please walk me through these lines? Does the js load when the is first loaded and will it post variables to a hidden form right away? If so, how is the hidden form displayed?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Very informative and helpful.
This function will be called when the page getting loaded,
$(function(){
This is to open new window
var win = window.open('', "mywindow");
create instant of a form using form id
var myform = $("#myform");
getting value by using the form control name
myform.find("#myattribute"
setting up the new window open "target" attribute
myform.attr("target", "mywindow");
auto form submit
myform.submit();
});