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

Object not supported by Method getElementbyID

Status
Not open for further replies.

walkerrv

Programmer
Jun 26, 2005
4
US
I have a problem that is kicking my butt.

I am a javascript newb. What I have is a list of values which I am pulling from a database to create my javascript. What I am doing it getting the Zip, city state from existing data and trying to populate city and state when zip exists.

Here is my script.

<script type="text/javascript">

function changeCityState() {
if (document.getElementbyID('Zip').value = '12345')
{
document.getElementbyId('City').value = 'TEST';
document.getElementbyId('State').value = 'CA';
}
if (document.getElementbyID('Zip').value = '67890')
{
document.getElementbyId('City').value = 'TEST!';
document.getElementbyId('State').value = 'MD';
}
}
</script>

Form
<form...>
<input name="Zip" type="text" id="Zip" size="6" value="" onChange="changeCityState()">
<input name="City" type="text" id="City" size="20" value="">,
<select name="State" id="State">
<option></option>
<option value="AL">Alabama</option>
<options...>
</select>
</form>

When I type in the zip and exit it I get a 'Object Not Supported by method.

What am I missing or doing wrong?

Any help would be greatly appreciated!

Thanks,
 

Simple... getElementByID was what you wanted. Javascript is case sensitive [smile]

Cheers,
Jeff

 
I figured it was something stupid, however I changed that and still got the same error. I was wondering if it is because I have a select box that it is trying to set the value of.

Any other ideas?

Thanks in advance for you help.

 
Nevermind I had another case problem on ID in the evaluation. I fixed it and it worked okay! Thanks
 

Your "if" statements should have "==" instead of "=" for the equality test.

Hope this helps,
Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Thanks, I was coming back to ask about that, cuz I was having issues.

I can do PHP blindfolded so I should have known that.

I fixed that and it fixed the problem before I asked what was going on.

Thanks in arrears for your help.

Working perfectly now!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top