|
-
Dec 3rd, 2005, 10:18 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Javascript: Assign innerHTML to DIV
Hi,
As the title suggests, I'm trying to dynamically assign the innerHTML of a DIV tag, but I can't get it to work. I've escaped the characters correctly, but I only get garbage. Here's some code so that you can see what I'm talking about.
VB Code:
<SCRIPT language="JavaScript">
function ProcessMediumSelection()
{
document.getElementById('divExpectedReturnDate2').innerHTML = '<script>DateInput(\\'ReturnDate\\', true, \\'DD-MON-YYYY\\')</script>';
}
Is it getting mixed up by the <script> tag in the HTML I'm trying to assign? When the page is rendered, fragments of the code above is shown at the top. Anyone know how I can do this?
-
Dec 3rd, 2005, 02:59 PM
#2
Re: Javascript: Assign innerHTML to DIV
< = <
> = >
& = &
" = "
These are the basic replacements to be made.
-
Dec 3rd, 2005, 03:27 PM
#3
Thread Starter
Fanatic Member
-
Dec 4th, 2005, 04:33 AM
#4
Re: Javascript: Assign innerHTML to DIV
You need to split the script end tag into two parts. Some HTML processors recognize it as the end of your actual script.
Code:
document.getElementById('divExpectedReturnDate2').innerHTML =
'<sc'+'ript>DateInput(\'ReturnDate\', true, \'DD-MON-YYYY\')</scr'+'ipt>';
However, I'm not sure if this means the browser will actually execute the new code. Besides, why would you WANT such confusing code?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 5th, 2005, 01:40 PM
#5
Thread Starter
Fanatic Member
Corned Bee ...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|