JavaScript and client side scripting.
Moderator: General Moderators
me666
Forum Commoner
Posts: 87 Joined: Wed Oct 08, 2008 5:04 pm
Post
by me666 » Mon May 03, 2010 12:19 pm
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
kaszu
Forum Regular
Posts: 749 Joined: Wed Jul 19, 2006 7:29 am
Post
by kaszu » Mon May 03, 2010 1:42 pm
When onchange event occurs use
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
Post
by me666 » Mon May 03, 2010 2:34 pm
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?