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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

errr...not making sence

Status
Not open for further replies.

filespace

Programmer
Jul 31, 2009
2
US
Code:
<html>
<head>

<script type="text/javascript" defer="defer">
function Rafter(){
var dropdownValue = document.getElementById('fromloc').value;
var changer = document.getElementById('fromAddress');

      if  (dropdownValue == "RDU Airport")    {
         changer.value = "1050 Airside Dr Morrisville, NC";
}
      if  (dropdownValue == "CLT Airport")    {
         changer.value = "5501 Josh Birmingham Parkway Charlotte, NC";
}
      else {
         changer.value = "Waiting on input...";
         }
      
}
</script> </head>
<body>

        <select size="1" name="fromloc" id="fromloc" onchange="Rafter();">
        <option value="select">Select from list or enter address below</option>    
        <option value="RDU Airport">RDU Airport</option>
        <option value="CLT Airport">CLT Airport</option>
                </select>
 
        
     <input type="text" name="from" id="fromAddress" size="15" /></td>
   
    </body>
    </html>

for some damn reason the clt works but rdu does not wtf? i cant seem to see what im missing
 
i scrapped this and used this method i fixed my own problem...

<html>
<head>

<script type="text/javascript" defer="defer">
function Rafter(){
var dropdownValue = document.getElementById('fromloc').value;
var changer = document.getElementById('fromAddress');



switch (dropdownValue)
{
case "RDU Airport":
changer.value = "RDU Airport"
break;
case "CLT Airport":
changer.value = "CLT Airport"
break;
case "ILM Airport":
changer.value = "ILM Airport"
break;
default:
changer.value = "Waiting on Input...";

}


}
</script> </head>
<body>

<select size="1" name="fromloc1" id="fromloc" onchange="Rafter();">
<option value="select">Select from list or enter address below</option>
<option value="RDU Airport">RDU Airport</option>
<option value="CLT Airport">CLT Airport</option>
<option value="ILM Airport">ILM Airport</option>
</select>


<input type="text" name="from" id="fromAddress" size="50" /></td>

</body>
</html>
 
Your initial problem was that your first if statement assigned one value to changer/b], but the second if statement with the else did a second assignment. The code SHOULD have been:
Code:
function Rafter(){
var dropdownValue = document.getElementById('fromloc').value;
var changer = document.getElementById('fromAddress');

      if  (dropdownValue == "RDU Airport")    {
         changer.value = "1050 Airside Dr Morrisville, NC";
}
      [b][red]else[/red][/b] if  (dropdownValue == "CLT Airport")    {
         changer.value = "5501 Josh Birmingham Parkway Charlotte, NC";
}
      else {
         changer.value = "Waiting on input...";
         }
      
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top