Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

changing font color based on form input

Status
Not open for further replies.

JDTornado

Technical User
Dec 6, 2001
5
US
Hi. I have been creating a page that changes certain parts of the page based on user input into forms. An example would be this:

<html>
<head>
<script LANGAUGE=&quot;JavaScript&quot;>
function getInfo() {
var title=document.info.title.value
newTitle=document.getElementById(&quot;head1&quot;)
newTitle.firstChild.nodeValue=title
}
</script>
</head>
<body>
<h1 ID=&quot;head&quot;>This is the old Tite</h1>
<form name=&quot;info&quot;>
<input type=&quot;text&quot; name=&quot;title&quot;>
<input type=&quot;button&quot; onClick=&quot;getInfo()&quot;>
</form>
</body>
</html>

--------------------
That's one of the parts of that page, I have the same setup for body text, and background colors. The delima I face now is how to change the font color and possibly the font of the text that has been entered. Any help with this will be greatly appreciated! Thanks!

JD

 
I changed head1 to head in your code and that will change the innerText property of your H1 tag with the id &quot;head&quot;.
To change the color of your h1 tag you can do the following:
<html>
<head>
<script LANGAUGE=&quot;JavaScript&quot;>
function getInfo() {
var newTitle=eval(&quot;head&quot;);
newTitle.style.color=&quot;red&quot;;
}
</script>
</head>
<body>
<h1 ID=&quot;head&quot; style=&quot;color: green&quot;>This is the old Tite</h1>
<form name=&quot;info&quot;>
<input type=&quot;text&quot; name=&quot;title&quot;>
<input type=&quot;button&quot; onClick=&quot;getInfo()&quot;>
</form>
</body>
</html>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top