Jump to content


Another JavaScript issue...


1 reply to this topic

#1 Flanders

    Young Padawan

  • Members
  • Pip
  • 53 posts
  • Gender:Female
  • Location:Gilbert, PA
  • Interests:web design, graphic design, photography, philosophy, politics, myst, the sims, maple story

Posted 24 January 2007 - 11:38 AM

I'm using the HTMLstring+= thingummy (I'm not really sure what the technical term for it is O.o) to write code to a new page. I want to write some more JavaScript into said other page though, but whenever I try to implement it, it spits back a bunch of code rather than displaying properly. Is there a trick to writing JavaScript to a new page, or an equivalent code to the HTMLstring that works with JavaScript?

Here's my code thus far, in case my description wasn't clear (which it probably wasn't, since I'm rather new to all this):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Backbone Test 1</title>

&lt;script langauge="Javascript" type="text/javascript">

<!-- Hide script from older browsers

function calculateOrder(passForm){
	if(passForm.ips.value == ""){
		alert("Please enter the number of your company's external IP addresses")
		passForm.ips.focus()
		return false
	}
	if(passForm.ips.value <= 4){
		passForm.ipsNew = passForm.ips
		HTMLstring='<HTML>\n';
		HTMLstring+='<HEAD>\n';
		HTMLstring+='<TITLE>New Document</TITLE>\n';
		HTMLstring+='</HEAD>\n';
		HTMLstring+='<BODY bgColor="#">\n';
		HTMLstring+='<P Style="color:#000000">Your total is $189</P>\n';
		HTMLstring+='</BODY>\n';
		HTMLstring+='</HTML>';
		newwindow=window.open();
		newdocument=newwindow.document;
		newdocument.write(HTMLstring);
		newdocument.close();
		return false
	}
	if(passForm.ips.value >= 5){
		passForm.ipsNew = ((passForm.ips.value - 4) * 25) + 189
		
		HTMLstring='<HTML>\n';
		HTMLstring+='<HEAD>\n';
		HTMLstring+='<TITLE>New Document</TITLE>\n';
		HTMLstring+='</HEAD>\n';
		HTMLstring+='<BODY bgColor="#">\n';
		HTMLstring+='<P Style="color:#000000">Your total is $'+passForm.ipsNew+'</P>\n';
		HTMLstring+='</BODY>\n';
		HTMLstring+='</HTML>';
		newwindow=window.open();
		newdocument=newwindow.document;
		newdocument.write(HTMLstring);
		newdocument.close();
		return false
	}
	return true
}

// End hiding script -->

</script>

</head>

<body>

<form onsubmit="return calculateOrder(this)" action="cgi-mailer.cgi" name="order">

Please enter the number of external IP addresses your company has: <input type="text" size="10" name="ips" />
<p><input type="submit" value="Submit" />

</form>

</body>
</html>


#2 fiv3isaliv3

    Young Padawan

  • Members
  • Pip
  • 258 posts
  • Gender:Male

Posted 25 January 2007 - 10:43 AM

Why not use a server side language to do this? It would make more sense then using something client side.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users