help with onChange document.write

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
me666
Forum Commoner
Posts: 87
Joined: Wed Oct 08, 2008 5:04 pm

help with onChange document.write

Post by me666 »

Hey all, i'm getting to grips with php but have a small javascript problem. I have a form below and need a little help adding an onChange=document.write for the dropdown box. I have added in the code where I want what values but am unsure as to how to implement it.

Code: Select all

<form action="?0&posts=5" method="post">
Update: <select name="color">
<option value="blue">Text Colour</option>
<option value="blue">Default</option>
<option value="red">Red</option>
<option value="green">Green</option>
<option value="purple">Purple</option>
<option value="orange">Orange</option>
<option value="yellow">Yellow</option>
<option value="brown">Brown</option>
<option value="black">Black</option>
</select>
//here I would like <font color="selected option value"> and by default <font color="blue"> //
<input type="text" name="update" value="Update text here...">
</font>
<input type="submit" name="upst" value="Update">
</form> 
Can anyone give me some advice on how to achieve this please? :)
Thanks all
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Re: help with onChange document.write

Post by kaszu »

When onchange event occurs use

Code: Select all

document.getElementById
to get <font> element and

Code: Select all

HERE_RETURNED_ELEMENT.setAttribute('color', ...);
method of element to change "color" attribute. You can wrap that text in P or DIV and also use document.getElementId and

Code: Select all

HERE_RETURNED_ELEMENT.style.display = 'block';
to show that text if it's not visible when page loads.
me666
Forum Commoner
Posts: 87
Joined: Wed Oct 08, 2008 5:04 pm

Re: help with onChange document.write

Post by me666 »

thanks for the reply, but i'm not familiar with javascript and so this help has really confused me :?
is there any chance you could show me with a small example please?
Post Reply