Google Groups Home
Help | Sign in
Question about literals
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Mtek  
View profile
 More options May 17, 2:59 pm
Newsgroups: comp.lang.javascript
From: Mtek <m...@mtekusa.com>
Date: Sat, 17 May 2008 11:59:43 -0700 (PDT)
Local: Sat, May 17 2008 2:59 pm
Subject: Question about literals
Hi,

We have a script where we are changing the innerHTML value.  To do
that, we have concatenated a string, and then we set it.

In one of those string is some javascript.  The javascript MUST exist
under the control which it is realted to.  The code below works fine
if in regular HTML.  But, we cannot get it to work when we make it
part of the string like this.  We're using some XML, but that is not
the problem, as it works fine when in regular HTML.    It is the
middle section that is in question:

      str = str + '<table cellspacing="0" cellpadding="0"
style="border-collapse: collapse">';
      str = str + '  <tr>';
      str = str + '    <td><span class=star>*  </span><input
type="text" name="RegDate" id="RegDate" readonly="1" VALUE=' +
getElementTextNS("", "reg_date", r[i], 0) + '></td>';
      str = str + '    <td>&nbsp;<img src="../images/admin2/
calendar_img.gif" id="f_trigger_c" style="cursor: pointer; border: 1px
solid red;" title="Reg Date" onmouseover="this.style.background=\'red
\';" onmouseout="this.style.background=\'\'"></td>';
      str = str + '  </tr>';
      str = str + '</table><br>';

--  This part is not working.

     str = str + '<script>';
     str = str + '  Calendar.setup({';
     str = str + '    inputField     :    "RegDate", ';
     str = str + '    ifFormat       :    "%B %e, %Y",';
     str = str + '    button         :    "f_trigger_c",';
     str = str + '    align          :    "Tl",';
     str = str + '    singleClick    :    true });';
     str = str + '<\/script>';

      str = str + '<BR><CENTER><span class=labels><B>Reg Date</
CENTER></TD>';
      str = str + '</TR>';
      str = str + '<TR><TD colspan=2><img src=\'../images/rsvp/
spacer.gif\' height=10></TD></TR>';
      str = str + '</table>';
      str = str + '</CENTER>';
      document.getElementById('details').innerHTML = str;

We get no errors, nothing at all.  It just does not work when we click
the button.   Any suggestions would help us out a lot!

Thanks!

John


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
VK  
View profile
(2 users)  More options May 17, 3:26 pm
Newsgroups: comp.lang.javascript
From: VK <schools_r...@yahoo.com>
Date: Sat, 17 May 2008 12:26:35 -0700 (PDT)
Local: Sat, May 17 2008 3:26 pm
Subject: Re: Question about literals
On May 17, 10:59 pm, Mtek <m...@mtekusa.com> wrote:

> We have a script where we are changing the innerHTML value.  To do
> that, we have concatenated a string, and then we set it.

> In one of those string is some javascript.  The javascript MUST exist
> under the control which it is realted to.

No it doesn't: stop this railed Ruby crap propaganda. And if you
really insisting  on raw source dumping into document, at least change
concatenations by   String concat() method. You'll be amazed by the
productivity growth on some browsers, I promise.

> The code below works fine
> if in regular HTML.  But, we cannot get it to work when we make it
> part of the string like this.

Right, script added by script as a raw source patch is not executed.
This is why btw many Ruby-type projects are falling apart as soon as
they get a bit more complex. A minimum code demonstrating your
problem:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta http-equiv="Content-type"
 content="text/html; charset=iso-8859-1">
<title>Demo</title>
<script type="text/javascript">
function init() {
 var demo = document.getElementById('demo');
 demo.innerHTML = ''.concat(
  '<script>window.alert("Will not work")<\/script>'
 );

}

function releaseContextAndInit() {
 window.setTimeout('init()',10);
}

window.onload = releaseContextAndInit;
</script>
</head>
<body>
<p id="demo"> </p>
</body>
</html>

If you are on a really severe time limit to re-write a descent
program, try to search at Ruby forums:
http://www.ruby-forum.com/search?query=javascript&submit=Search
They are continuously looking for fixes for exactly such situations so
maybe someone came with a fix.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google