Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forms and java script

Status
Not open for further replies.

help120

Technical User
Apr 15, 2001
198
US
I want a window to open up after some one fills out this form.

This is the form code:
<form action=&quot;gy/mail_fp.asp&quot; method=&quot;POST&quot;>
<p style=&quot;margin-top: 0; margin-bottom: 0&quot;>
<input class=&quot;shade&quot; type=&quot;text&quot; name=&quot;email&quot; size=&quot;11&quot;>
<BR>
</p>
<div align=&quot;left&quot;>
<div align=&quot;left&quot;>
<table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;
style=&quot;border-collapse: collapse&quot; bordercolor=&quot;#111111&quot; width=&quot;129&quot;
id=&quot;AutoNumber8&quot;>
<tr>
<td width=&quot;100%&quot; align=&quot;right&quot; valign=&quot;top&quot;>
<p style=&quot;margin-top: 0; margin-bottom: 0&quot;>&nbsp;<input src=&quot;images/submit.gif&quot; type=&quot;image&quot; type=&quot;submit&quot; value=&quot;Submit&quot; alt=&quot;Join&quot; name=&quot;submit&quot; width=&quot;28&quot; height=&quot;7&quot;>
</td>
</tr>
</table>
</div>
</div>
</form>

This is the java script code:

<script language=&quot;JavaScript&quot;>
<!-- hide from JavaScript-challenged browsers
function openWindow(url) {
popupWin = window.open(url,'new_page','width=400,height=450')
}
// done hiding -->
</script>

This is the code to link to the javascript:

JavaScript:eek:penWindow('gy/mail_fp.asp')

I tryed putting the &quot;&quot;JavaScript:eek:penWindow('gy/mail_fp.asp')&quot;&quot; in the action area and it works but... the user still has to type in their e-mail addy.
 
Could you be more specific? Are you trying to validate an email address? If the email address is valid, then the user can submit the form and pop open the window?
 
-------------
TRY THIS OUT
-------------

<form name=&quot;form1&quot; action=&quot;javascript:validate();&quot; method=&quot;POST&quot;>
<p style=&quot;margin-top: 0; margin-bottom: 0&quot;>
<input class=&quot;shade&quot; type=&quot;text&quot; name=&quot;email&quot; size=&quot;11&quot;>
<BR>
</p>
<div align=&quot;left&quot;>
<div align=&quot;left&quot;>
<table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;
style=&quot;border-collapse: collapse&quot; bordercolor=&quot;#111111&quot; width=&quot;129&quot;
id=&quot;AutoNumber8&quot;>
<tr>
<td width=&quot;100%&quot; align=&quot;right&quot; valign=&quot;top&quot;>
<p style=&quot;margin-top: 0; margin-bottom: 0&quot;>
<input src=&quot;images/submit.gif&quot; type=&quot;submit&quot; value=&quot;Submit&quot; alt=&quot;Join&quot; name=&quot;submit&quot; width=&quot;28&quot; height=&quot;7&quot;>
</td>
</tr>
</table>
</div>
</div>
</form>

This is the java script code:

<script language=&quot;JavaScript&quot;>
<!-- hide from JavaScript-challenged browsers
function openWindow(url) {
popupWin = window.open(url,'new_page','width=400,height=450')
}

function validate()
{
if( (document.form1.email.value.length <= 0) ||
(document.form1.email.value.indexOf('@') <0 ) )
{
alert('You must enter in a valid email address.');
}
else
{
openWindow('gy/mail_fp.asp');
}

}
// done hiding -->
</script>


--------
ALSO
--------
Be sure to watch your the properites that you are placing for your fields. It looks to me like you have two seperate type properties declared 'type=&quot;image&quot; type=&quot;submit&quot;'. A type submit will always work fine. If you are going to use an image as you submit, then you need to add an <a> tag around the image or include an onClick event.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top