Jump to content

[SOLVED] Javascript as a Form action


Esqulax

Recommended Posts

Hiya

 

Im trying to open a pop up window when a button is clicked..the code i have works at the bottom as an <a href...>, but wont do is as a form action at the top...any idea what im doing wrong?

 


<table border="0" width="730" align="center" bgcolor="">
<tr>
	<td colspan="4" align="center">
		<img src="image/guest/guestmain.gif">
         </td>
         </tr>

<tr align="center">
<form method="post" action="javascript: window.open('add.php', 'Add Guest', 'width =400, height = 400');">
	<td><button value="Add Guest" type="submit"><img src="image/guest/addguest.png" width=40 height=40></button></td>
     </form>
    
<!-- Other table elements, removed for forum-->

	<tr align="center">
            <td><a href="javascript: window.open('add.php', 'Add Guest', 'width =400, height = 400');"><img src="image/guest/addimg.gif"></a></td>


	</tr>
        
  	</table>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/79695-solved-javascript-as-a-form-action/
Share on other sites

ok, you use the onSubmit event for doing something when the form is submited, but I have no idea why on earth you want to do it on form action, I mean why a form, the form is not going to post the values to you popup window.

 

Is it so you dont have to create a button.

here is the code

<form method="post" onSubmit="window.open('add.php', 'Add Guest', 'width =400, height = 400'); return false;" action="">
	<td><button value="Add Guest" type="submit"><img src="image/guest/addguest.png" width=40 height=40></button></td>
</form>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.