i got 2 questions to ask
1.
i ‘m trying to change the background color in the input field after i select color from the dropdown list. but it’s just give me the name of the color in the input field instead of the color changing. so what did i do wrong in the getcolor fuction?
i ‘m trying to load pic from the drop down list. but i don’t know what’s wrong with the showflag function.
please give me an example with ur explanation. thanks!
<HTML>
<HEAD><TITLE> ASSIGNMENT4 </TITLE>
<script type=”text/javascript”>
function getcolor()
{
txt=document.forms[0].color.options[document.forms[0].color.selectedIndex].text
document.forms[0].SOURCEBOX.value=txt
}
</script>
<script>
function getfont()
{
txt=document.forms[0].font.options[document.forms[0].font.selectedIndex].text
document.forms[0].SOURCEBOX.value=txt
}
</script>
<script>
function changeFlag()
{
var FlagFile = new Array (“blank.gif”, “US.gif”, “Canada.gif”);
var FlagText = new Array (“”, “US Flag”, “Canada Flag”);
var selection = document.ShowFlag.Flag.selectedIndex;
var theChoice = document.ShowFlag.Flag.options[selection].value;
document.pic.src = FlagFile[theChoice];
document.all.picWords.innerText = FlagText[theChoice];
}
</script>
<form method = “post”>
Name:<br> <input type=”text” name=”name” size=”29″><br>
Age:<br> <input type=”text” name=”age” size=”29″><br>
Please Complete: <br><TEXTAREA NAME= “SOURCEBOX” ROWS=”10″ COLS=”30″WRAP=”HARD”></TEXTAREA><br>
<BR>
<BR>
<form>
<select name=”color” onchange=”getcolor()”>
<option value=”color choices”>Color Choices
<option value=”pink” style=”color:pink”>Pink
<option value=”tan” style=”color:tan”>Tan
<option value=”cyan” style=”color:cyan”>Cyan
</select>
<select name=”font”onchange=”getfont()”>
<option value=”FontSize Choices”>FontSize Choices
<option value=”Regular”>Regular
<option value=”Medium”>Medium
<option value=”Large”>Large
</select>
</form>
<form NAME=”ShowFlag”>
<select name=”Flag” onChange=”changeFlag()”>
<option value=”Choose a Flag “>Choose a Flag
<option value=”US.GIF”>US
<option value=”Canada.GIF”>Canada
<option value=”None”>None
</select>
</form>
<IMG SRC=”blank.gif” NAME=”pic” BORDER=”0″>
<SPAN ID=”picWords” NAME=”picWords”></SPAN>
<P><INPUT TYPE=”SUBMIT” VALUE=”Send”>
</HTML>