PDA

View Full Version : Writing HTML from a script


Genelle
11-15-2002, 08:25 PM
I have a script that when you click a button a portion of text is written to a table cell.

However when I try to write more than just text by using any HTML tag, the code gets literally printed on the page and not interpreted as HTML

Say for example I want to format that cell's text, put in a form,
or use other tags (dropping in another web page with an ssi file include <!-- file include......-->

Is there some way to comment out that literal interpretation? In perl for example I know you can tell the language to "interpolate the following" with qq(<stuff>). Does javascript have something similar?

I get the feeling that document.writeln() could be a help here however I am fairly new to Javascript and have no idea where to put it - I know it ll need to be somewhere under the 'put' function but have no idea how to incorporate it.

My script is here http://pages.sbcglobal.net/nordallc/cellfillcombo.htm

Any help would be appreciated :)

Thanks!

beetle
11-15-2002, 09:06 PM
The link you provided doesn't even show us the problem you are experiencing. I do see a couple things wrong (bad HTML, the put function is in there twice) but nothing that I see yet that would cause the error you describe. I suspected that innerText was being used instead of innerHTML, but it is not, so I need to see your error take place to determine the cause of the problem.

Roy Sinclair
11-15-2002, 09:26 PM
Quotes marks are NOT optional!

Because the browsers are too lax to enforce good coding policies people learn bad habits and those bad habits then come back and bite them later because they've never learned or totally forgotten basic things that ought to be habits.

Instead of this:


<input type="button" value="Tab One" text=a onclick="put('cell1',this.text)">


You should have this:


<input type="button" value="Tab One" text="<h1>a</h1>" onclick="put('cell1',this.text)">

Genelle
11-20-2002, 08:28 AM
It was the quote marks. Thanks! I tried to clean up the HTML too - the script is sort of a cut and paste of stuff ive found elsewhere :)~

Having a new problem though - posted it already - but visit this link to see whats going on now

http://host16.ipowerweb.com/~nordalap/index.shtml

Vladdy
11-20-2002, 08:33 AM
.....That is one wierd way to accomplish the task at hand....
Where did you find this approach???

Roy Sinclair
11-20-2002, 06:08 PM
You have multiple problems with the new page. I see you're trying to user server side includes to bring in the contents of external files as tabs in your page via these text values. That's not going to work very well because your additional files have embedded quote marks which prematurely end the text="your file here" string, the embedded carriage returns also have the same effect and the browser then interprets the rest of the html in your included files.

Perhaps you should use the <iframe> tag to include this content, then your code would be a lot simpler.