I'm trying to use jquery to :
- open a new window/tab (same domain, different page)
- then add text to a text box (
id = "BUpdates_SQL_Statement"
) - then click this button:
<input type="submit" value="Apply Changes" name="BUpdates_Submit" id="BUpdates_Submit">
- then close the window
here's the onclick element in the starting page (we'll call it www.mydomain.com/firstpage):
<li id="MainNav_Update"><span class="MainMenuText" onclick="runUpdateWindow();">Update</span></li>
and here's the area I want to edit in the new window (we'll call it www.mydomain.com/secondpage)
<textarea id="BUpdates_SQL_Statement"></textarea>
<input type="submit" value="Apply Changes" id="BUpdates_Submit">
<a onclick="v$('BUpdates_Submit').click();return false;" href="javascript:void(0);"><span>Apply Changes</span></a>
side note: v$('BUpdates_Submit').click();return false;"
is for another external js file that has nothing to do with what I'm trying to do here.
and here's my jquery:
function runUpdateWindow() {
var updateWindow = window.open("www.mydomain.com/secondpage", "blank");
}
var updateSQL = 'UPDATE TABLE ...';
$(updateWindow).on("load", function (){
$("BUpdates_SQL_Statement", updateWindow.document).append(updateSQL);
$('BUpdates_Submit').trigger('click');
});
updateWindow.close();
The www.mydomain.com/secondpage
is opening in a new tab, but the BUpdates_SQL_Statement
should be:
<textarea id="BUpdates_SQL_Statement">
UPDATE TABLE...
</textarea>
but it's still blank.
I would sincerely appreciate any input. Thanks in advance!