Jump to content


Photo

<a onclick=".. not working


  • Please log in to reply
1 reply to this topic

#1 manamino

manamino
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 20 April 2006 - 04:45 AM

hi, I have a problem, I have the below code where the table and href shold be inside javascript using document.write
if I put onclick="..." inside the <a > It's not working and I have eror on page after clicking
what is the problem?


[!--coloro:#009900--][span style=\"color:#009900\"][!--/coloro--]<html>
<head>

<script language="JavaScript">

function submitting(forum)
{
document.write(forum) //this is only a test
}

function loading()
{
var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.load("forums.xml");
var doc=xmlDoc.documentElement;
for(var i=0; i<doc.childNodes.length; i++)
display(doc.childNodes(i));
}

function display(cat)
{
document.write('<a name="top"></a><TABLE cellspacing="1" width="100%" bgcolor="#99ccff" border="2" ><TR><TH bgcolor="#ffff99" COLSPAN="3" ALIGN="LEFT">'+cat.getAttribute("NAME")+'</TH></TR>');
document.write('<TR bgcolor="#33cccc" ><TD width="80%">Forum</TD><TD width="10%">Topics</TD><TD width="10%">Replies</TD></TR>');
for(var j=0;j<cat.childNodes.length;j++)
{var node=cat.childNodes(j);
document.write('<TR><TD><a href="#top" onclick="submitting(\''+node.childNodes(0).firstChild.text+'\')">'+node.childNodes(0).firstChild.text+'</a><br><FONT COLOR="GRAY">'+node.childNodes(1).firstChild.text+'</FONT></TD><TD>'+node.childNodes(2).firstChild.text+'</TD><TD>'+node.childNodes(3).firstChild.text+'</TD></TR>');


}
document.write('</TABLE>');
}
</script>
</head>
<body onload="loading()">

<form name='forums' action='posts.php' method='post'>
<input type='hidden' name='forum'/>
</form>
</body>
</html>[!--colorc--][/span][!--/colorc--]


but if I tried alert instead of submitting it works:


#2 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 28 April 2006 - 02:21 AM

add " at the end of onclick="whatever"

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users