jquery - How to change the action on a form in a popup? -
i have jquery included change action of form on popup page want have window opener able control form action of popup... possible?
popup html:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <body onload=chgaction();> <script> function chgaction() { $('#search').attr('action', 'mynewactiontarget.html'); } </script> <base href="http://vahud.com/"> <form id="search" method="get" action="dowork.php"> first name <input type="text" name="fname" value="tom"><br> last name <input type="text" name="lname" value="chambers"><br> <input type="submit" class="form-submit" value="search"> </form> this in window opener.. , above form in myform.htm popup.. want able move action changer down here window opener page.. same result in form..
window opener js:
window.open('myform.htm','mywindow','width=300,height=300');
you're there. need wrap javascript in document.ready binds after form exists.
$(document).ready(function() { var popup = window.open('/' + window.url_prefix + '/', '_blank'); popup.onload = function() { $(popup.document.body).attr('action', 'mynewactiontarget.html'); }; chgaction(); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <body> <base href="http://vahud.com/"> <form id="search" method="get" action="dowork.php"> first name <input type="text" name="fname" value="tom"> <br>last name <input type="text" name="lname" value="chambers"> <br> <input type="submit" class="form-submit" value="search"> </form>
Comments
Post a Comment