Hi, all. This may actually be more of an HTML/Javascript question rather
than a dynapi question: if so, please feel free to refer me to "tfm" so I
can "r" it. :)

I have defined a layer and used myLayer.setHTML() with a quite long
string including <div>, style tags for font, and some text, like this:

 myLayer.setHTML('<div valign="center" style=" text-align: $alignment;
 font-size: 30px; line-height: 0px; font-family: Courier"><font
 face="Courier" color="#00FFFF"><b><i>Some Text</i></b></font></div>')
 
(I need all that style info because the layers need to emulate what would
be printed on a printer fairly closely, and this is about the only way I
can do it.) This works great for setting up the layer. But here's the
problem: In the main document, I have a form, e.g:

 <form name=myForm action="blahblah.cgi">
 Name: <input type=text name=Name value="Something">
 </form>

The idea is that when they type something into that input slot, it
automatically updates the text part of the HTML in the layer. Now, in the
input field, I've put:

onChange="myLayer.setHTML('<the same html>' + myForm.Name.value + '</the
same html>?');"

What I want to happen is that when they change the text in the field, it
updates *just* the text part of the HTML in the layer, but keeps all the
style and font information in the layer display. However, while I can
assign the HTML fine in the beginning, I have problems using onChange in
the form field because of the "" in the "style=" line for the setHTML tag.
If I keep the "" around the style tag, it becomes an unterminated string.  
If I use &#34; or &quot; for the quotes around the style tag, it does not
error, and changes the layer, but loses all the style information.  If I
just backslash the quotes, of course that doesn't work either, but I
thought I'd try it anyway. :)

The only other thing I could think of was maybe to do something like this:
at the beginning of DynAPI.onLoad=function ():

myLefthtml = '<html with all the style stuff>';
myRighthtml = '</html with all the style stuff>';

then do something like 

 onChange="myLayer.setHTML(myLefthtml + form.field.value + myRighthtml);"

This works in IE, but not NS4 (in NS4, it changes the text string, but
again loses all the style information). Thanks for any info...I may just
be stuck with this. I believe this may just be the nature of the beast
with HTML and Javascript, but wondered if anyone had ever encountered this
or found a workaround?

Kristina


_______________________________________________
Dynapi-Help mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-help

Reply via email to