4 Replies - 1130 Views - Last Post: 15 December 2008 - 05:46 PM

#1 asit_dhal  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 02-December 08

xml and javascript

Posted 15 December 2008 - 11:46 AM

What is wrong with this code ????

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	<title>DOM Example-1</title>
	<script language="javascript" type="text/javascript">
		function display() {
			var xmldata1 = document.getElementById("xmldata1");
			var bizCard = xmldata1.getElementsByTagName("BusinessCard")[0];
			var name = bizCard.getElementsByTagName("Name")[0].firstChild.data; 
			aler("Name : " + name);
		}
	</script>
</head>
<body>
	<xml id="xmldata1" style="display:none">
		<BusinessCard>
			<Name>Joe Marini</Name>
			<phone type="mobile">(415) 555-4567</phone>
			<phone type="work">(800) 555-9876</phone>
			<phone type="fax">(510) 555-1234</phone>
			<email>[email protected]</email>
		</BusinessCard>
	</xml>
	<a href="java script:display()">Display Businesscard</a>
</body>
</html>



Is This A Good Question/Topic? 0
  • +

Replies To: xml and javascript

#2 asit_dhal  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 02-December 08

Re: xml and javascript

Posted 15 December 2008 - 11:48 AM

What is wrong with this code ????

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	<title>DOM Example-1</title>
	<script language="javascript" type="text/javascript">
		function display() {
			var xmldata1 = document.getElementById("xmldata1");
			var bizCard = xmldata1.getElementsByTagName("BusinessCard")[0];
			var name = bizCard.getElementsByTagName("Name")[0].firstChild.data; 
			aler("Name : " + name);
		}
	</script>
</head>
<body>
	<xml id="xmldata1" style="display:none">
		<BusinessCard>
			<Name>Joe Marini</Name>
			<phone type="mobile">(415) 555-4567</phone>
			<phone type="work">(800) 555-9876</phone>
			<phone type="fax">(510) 555-1234</phone>
			<email>[email protected]</email>
		</BusinessCard>
	</xml>
	<a href="java script:display()">Display Businesscard</a>
</body>
</html>


Was This Post Helpful? 0
  • +
  • -

#3 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon


Reputation: 6979
  • View blog
  • Posts: 14,605
  • Joined: 16-October 07

Re: xml and javascript

Posted 15 December 2008 - 12:22 PM

No "t" in alert and a space between java and script in the href.
Was This Post Helpful? 0
  • +
  • -

#4 JohnWaters  Icon User is offline

  • D.I.C Head

Reputation: 12
  • View blog
  • Posts: 140
  • Joined: 28-November 08

Re: xml and javascript

Posted 15 December 2008 - 01:56 PM

NOTE: This might be a little bug in this rich text editor.

I tried entering the same <a href=...> tag (within the code tag) in this editor and it put a space between java & script (java script)

Strange.

This post has been edited by JohnWaters: 15 December 2008 - 01:58 PM

Was This Post Helpful? 0
  • +
  • -

#5 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1485
  • View blog
  • Posts: 8,204
  • Joined: 07-September 06

Re: xml and javascript

Posted 15 December 2008 - 05:46 PM

Please don't post duplicate topics. Merged.

Quote

NOTE: This might be a little bug in this rich text editor.

No, that isn't a bug. It separates Java and Script to avoid html/JS based security issues (like links that try to do strange things and so forth).

Not sure what it is supposed to do, but you do have a typo in "aler" < notice the missing "t"

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	<title>DOM Example-1</title>
	<script language="javascript" type="text/javascript">
		function display() {
			var xmldata1 = document.getElementById("xmldata1");
			var bizCard = xmldata1.getElementsByTagName("BusinessCard")[0];
			var name = bizCard.getElementsByTagName("Name")[0].firstChild.data; 
			alert("Name : " + name);
		}
	</script>
</head>
<body>
	<xml id="xmldata1" style="display:none">
		<BusinessCard>
			<Name>Joe Marini</Name>
			<phone type="mobile">(415) 555-4567</phone>
			<phone type="work">(800) 555-9876</phone>
			<phone type="fax">(510) 555-1234</phone>
			<email>[email protected]</email>
		</BusinessCard>
	</xml>
	<a href="java script:display()">Display Businesscard</a>
</body>
</html>



Again, I wasn't really sure what you were trying for.

Hope that helps.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1