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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

urgent: trying to open a new asp page from a submit on a form with JS

Status
Not open for further replies.

hemal666

Programmer
Dec 10, 2001
25
GB
Hey there people,
Im trying to open a new window from an html page using the submit button on a form. This is not a problem, however i do not want the address bar to open and i want to control the size of the window. With my current code the new window will open (no address bar and the correct size). However my asp request.form are not picking up the sent information. Ive racked my brain to try to find a solution. please help!!!thanx in advance

heres the code for the initial html page:
Code:
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<html>
<head>
<title>hillcrest plus - request information</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot; />
<script language=&quot;JavaScript&quot; type=&quot;text/JavaScript&quot;>
//New window operation
function newWindow(hcresta){
hcrestaWindow = window.open(hcresta,'newWin','location=no,toolbar=no,width=500,height=500')
hcrestaWindow.focus()
}
// Valid info selection
function validinfo (info) {
if (info ==&quot;Make a Selection&quot;) {
return false
}
return true
}
function validother (other) {
if (other == &quot;&quot; && reqinfo.info.value == &quot;Other&quot;) {
return false
}
return true
}
// validate name
function validname (custnme)   {
if (custnme ==&quot;&quot;) {
return false 
}
return  true
}
// validate the address
function validaddress (custadd1) {
if (custadd1 ==&quot;&quot;) {
return false
}
return true
}
//validate the post code
function validpc (custpc) {
if (custpc ==&quot;&quot;) {
return false
}
return true
}
// Validate the telephone number  
function validtel (custtel)   {
if (custtel ==&quot;&quot;)  {
return false 
}
return  true
}	
//Check number
function isNum(passedVal) {
  if (passedVal == &quot;&quot;) {
    return false
  }
  for (i=0; i<passedVal.length; i++) {
    if (passedVal.charAt(i) < &quot;0&quot;) {
      return false
    }
    if (passedVal.charAt(i) > &quot;9&quot;) {
      return false
    }
  }
  return true
}
// Validate the e mail address
function validEmail(custemail) {
	invalidChars =&quot;/:,;&quot;
	if (custemail == &quot;&quot;) {
		return false  // Check not empty
	}
	for(i=0; i<invalidChars.lenght; i++) {
		badChar = invalidChars.charAt(i)
		if (custemail.indexof(badCar,0) > -1){
			return false //Check for invalid charecters
		}
	}
	atPos = custemail.indexOf(&quot;@&quot;,1)
	if (atPos == -1){
		return false //Check for One @ sign
	}
	if (custemail.indexOf(&quot;@&quot;,atPos+1) != -1) {
		return false  // check for more @ signs
	}
	fullstopPos = custemail.indexOf(&quot;.&quot;,atPos)
	if (fullstopPos == -1) {
		return false // check for a full stop after the @
	}
	if (fullstopPos+3 > custemail.length) {
		return true // Check 2 charecters after the full stop
	}
return true
}
//Execute the valitation function
function submitform(check) {
if(!validinfo(check.info.value)) {
alert(&quot;Plaese make a selection for the information you require&quot;)
check.info.focus()
return false
}
if(!validother(check.other.value)) {
alert(&quot;You have selected other information.  Please provide more detail&quot;)
check.other.focus()
check.other.select()
return false
}
if(!validname(check.custnme.value)) {
alert(&quot;No Name Has Been Entered&quot;)
check.custnme.focus()
check.custnme.select()
return false
}
if (!validaddress(check.custadd1.value)) {
alert(&quot;No Address has been entered&quot;)
check.custadd1.focus()
check.custadd1.select()
return false
}
if (!validpc(check.custpc.value)) {
alert(&quot;No post code has been entered&quot;)
check.custpc.focus()
check.custpc.select()
return false
}
if(!validtel(check.custtel.value)) {
alert(&quot;No Telephone Number Has Been Entered&quot;)
check.custtel.focus()
check.custtel.select()
return false
}
if(!isNum(check.custtel.value)) {
alert(&quot;An invalid Telephone Number Has Been Entered&quot;)
check.custtel.focus()
check.custtel.select()
return false
}
if(!validEmail(check.custemail.value)) {
alert(&quot;No Email Address or An Invalid Email Has Been Entered&quot;)
check.custemail.focus()
check.custemail.select()
return false
}

return true
}
</script>
</head>

<body link=&quot;#0094c2&quot; alink=&quot;#0094c2&quot; vlink=&quot;0094c2&quot;>
<font face=&quot;Helvetica Light&quot; color=&quot;##0094C2&quot; pointsize=&quot;15&quot;>
<table align=&quot;center&quot; border=&quot;0&quot;>
<tr><td><p><img src=&quot;images/serv.gif&quot; /></p></td></tr>
<tr><td><p>Please make a selection from the list below and enter your details</p>
<form action=&quot;javascript:newWindow('[URL unfurl="true"]http://www.pjosiah.co.uk/hillcrest/reqinfo.asp')&quot;[/URL] method=&quot;post&quot; name=&quot;reqinfo&quot; class=&quot;service&quot; id=&quot;reqinfo&quot; onSubmit=&quot;return submitform(this)&quot;>
<p>
I would like more information on <select name=&quot;info&quot;>
								<option selected value=&quot;Make a Selection&quot;>Make a Selection</option>
								<option value=&quot;Accupunture&quot;>Accupunture</option>
								<option value=&quot;Chiropody&quot;>Chiropody</option>
								<option value=&quot;Travel Heath Services&quot;>Travel Heath Services</option>
								<option value=&quot;Blood Pressure Monitoring&quot;>Blood Pressure Monitoring</option>
								<option value=&quot;Chinese Herbal Therapy&quot;>Chinese Herbal Therapy</option>
								<option value=&quot;Prescription Collection service&quot;>Prescription Collection Service</option>
								<option value=&quot;Ayurvedic&quot;>Ayurvedic</option>
								<option value=&quot;Smoking Cessation&quot;>Smoking Cessation services</option>
								<option value=&quot;Chiropractic&quot;>Chiropractic</option>
								<option value=&quot;Other&quot;>Other</option>
							</select> hillcrest service.
</p></td></tr>
<tr><td><p>If other, please provide details <input type=&quot;text&quot; name=&quot;other&quot; value=&quot;&quot;></p></td></tr>
<tr><td><p>
<table border=&quot;0&quot;>
	<tr>
		<td>Name</td>
		<td><input type=&quot;text&quot; name=&quot;custnme&quot;>*</td>
	</tr>
	<tr>
		<td>Address</td>
		<td><input type=&quot;text&quot; name=&quot;custadd1&quot;>*</td>
	</tr>
	<tr>
		<td></td>
		<td><input type=&quot;text&quot; name=&quot;custadd2&quot;></td>
	</tr>
	<tr>
		<td>Post Code</td>
		<td><input type=&quot;text&quot; name=&quot;custpc&quot;>*</td>
	</tr>
	<tr>
		<td>Telephone Number</td>
		<td><input type=&quot;text&quot; name=&quot;custtel&quot;>*</td>
	</tr>
	<tr>
		<td>Email Address</td>
		<td><input type=&quot;text&quot; name=&quot;custemail&quot;>*</td>
	</tr>
	<tr>
		<td><input name=&quot;reset form&quot; type=&quot;reset&quot; value=&quot;Reset Form&quot;></td>
		<td><input name=&quot;Submit&quot; type=&quot;submit&quot; value=&quot;Submit Your Reqest&quot;></td>
	</tr>
</table>
</p></td></tr>
</form>
<tr><td><p>Please note fields marked with an asterix (*) are compulsary.</p></td></tr>
<tr><td><p><img src=&quot;images/closewin.gif&quot; border=&quot;0&quot; usemap=&quot;#closewindow&quot; />
  <map name=&quot;closewindow&quot; id=&quot;closewindow&quot;>
  <area shape=&quot;rect&quot; coords=&quot;52,24,200,52&quot; onClick=&quot;javascript:self.close();&quot; />
  </map>
</p></td></tr>
</table>
</font>
</body>
</html>
thanx again
 
If you are submitting the form to the pop window, add a target to the <form> tag...

<form name=&quot;myForm&quot; target=&quot;newWinName&quot; action=&quot;aspPage.asp&quot;>

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
cheers for looking at this, i've added the target window name. The form element now looks like this
Code:
<form action=&quot;[URL unfurl="true"]http://www.pjosiah.co.uk/hillcrest/reqinfo.asp&quot;[/URL] method=&quot;post&quot; target=&quot;hcresta&quot; name=&quot;reqinfo&quot; class=&quot;service&quot; id=&quot;reqinfo&quot; onSubmit=&quot;return submitform(this)&quot;>
this works (as in the data is passed onto the next page) however i still don't have cotrol over the pop up. so im presuming that i still need the JS to spawn the new window with the lack of a toolbar. I subsequently tried the following
Code:
<form action=&quot;javascript:newWindow('[URL unfurl="true"]http://www.pjosiah.co.uk/hillcrest/reqinfo.asp')&quot;[/URL] method=&quot;post&quot; target=&quot;hcresta&quot; name=&quot;reqinfo&quot; class=&quot;service&quot; id=&quot;reqinfo&quot; onSubmit=&quot;return submitform(this)&quot;>
following this i still have no data being sent through. Im still a little confused.
 
Here's how I do it....

<script>
function subForm(){
//insert form validation here
//if form is valid, open a pop-window & submit
subWin = window.open(&quot;blank.htm&quot;,&quot;subWin&quot;,&quot;width=100,height=100,addess=no&quot;)
document.myForm.action = &quot;aspPage.asp&quot;
document.myForm.method = &quot;post&quot;
document.myForm.target = subWin
document.myForm.submit()
}
</script>
<form name=&quot;myForm&quot;>
..
..
..
<input type=button onCLick=&quot;subForm()&quot; value=&quot;Submit&quot;>
</form>

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
hi thanx again for your help.
however im stillunable to control the properties of the asp page. The properties of blank.htm are controlled fine.
still a little lost!

thanx H
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top