PDA

View Full Version : Using javascript variables with html


bookworm
10-31-2003, 02:57 PM
hi

okay, im making a font generator and i can get the stuff to show up in the text area but i also want the text to show up underneath with the color and size and font that the person wanted.

I have the font, color and size in variables name font, fontcolor and fontsize, respectively. I need to know how to type the html using these variables.

Heres what it looks like so far. http://www.geocities.com/bookworm15m/Pages/fontgenerator.html

if you can help, that would be greatly appreciated

Edit::.. oops, link didnt go to the right place
Edit2::.. Im guessing this is a bit confusing. okay, what im trying to say is. I want to type the html element with the variables in it.

like this.
<font color="variable" size="variable" face="variable">stuff</font>
obviously that doesnt work. I want to know how to make something like that work.

Danne
10-31-2003, 03:42 PM
If mean you want to show the HTML:

//...
if (marquee=="yes")
{
document.fontgen.changedtext.value='<marquee><font color="'+fontcolor+'" size="'+fontsize+'" face="'+font+'">'+yourtext+'</font></marquee>'
document.getElementById("htmlOutput").innerHTML=document.fontgen.changedtext.value;
}

//...

</script>

<div id="htmlOutput"></div>

bookworm
10-31-2003, 03:46 PM
wow, thanks, it works.