I guess you could say I'm fairly new to javascript, so this might be a silly coding mistake of mine. Here is the problem:
I've created a page in which the user can click on a button to call Function 1 using onClick. This function writes out a whole new HTML page using document.write. In this 'new page', it creates yet another button, which is
supposed to call Function 2 using onClick. The problem is, when you click on this button you get an error in IE 6.
----------------------------
Line: 1
Char: 1
Error: Object Expected
----------------------------
Yeah, well, that doesn't help me much, except now I know that for some reason, the browser can't find Function 2. Here's a simplified version of my code below:
Code:
<input type='button' value='Click Here' onClick='Test()'>
<!----------------------------------------------->
<script type='text/javascript'>
function Test()
{
document.write("<input type='button' value='Click Here' onClick='AnotherTest()'>")
}
function AnotherTest()
{
document.write("This text won't show up because of the problem!")
}
</script>
<!----------------------------------------------->
In the function 'AnotherTest', look at what I've written. See if that text shows up in your browser. It doesn't show up in Firefox 2.0.0.1 and IE 6.0, I'm pretty sure. Why? What is wrong with the code?
Hope someone can help me out!
Thanks a lot,
Dalal