dawesley
asked on
Getting error: Microsoft JScript runtime error: Object doesn't support this property or method
I'm programming in Visual Studio 2005.
I have an web page with an HTML (not ASP HTML) dropdownlist object.
I can't use 'runat=server' on the dropdownlist because it contains literals
and Microsoft won't accept them.
I want to return the value of the dropdownlist to the ASP server.
To do this, I'm trying to store the value of the dropdownlist in a hidden text field.
The dropdownlist HTML looks like this (not showing entire list)
<SELECT id=ddlCountry size=1 name=country_origin onchange='storeValue(this) '
Style="z-index: 130; left: 416px; position: absolute; top: 328px">
<OPTION selected>Select
one</OPTION>
<OPTGROUP label="North American Countries">
<OPTION value="United States">United
States</OPTION>
<OPTION value=Canada>Canada</OPTIO N>
<OPTION value=Mexico>Mexico</OPTIO N>
</OPTGROUP>
</SELECT>...
The hidden text field is:
<input id="hdnCountry" style="z-index: 131; left: 288px; position: absolute; top: 464px"
type="hidden" runat=server/>
The script that I'm running in the onchange event of the dropdownlist is:
<script type="text/javascript">
function storeValue(what)
{
document.getElmentById('hd nCountry') .value = what.value
}
</script>
When I select a value from the dropdownlist, I get the following error in the
Java script: Microsoft JScript runtime error: Object doesn't support this property or method
Much thanks to anyone who can help.
I have an web page with an HTML (not ASP HTML) dropdownlist object.
I can't use 'runat=server' on the dropdownlist because it contains literals
and Microsoft won't accept them.
I want to return the value of the dropdownlist to the ASP server.
To do this, I'm trying to store the value of the dropdownlist in a hidden text field.
The dropdownlist HTML looks like this (not showing entire list)
<SELECT id=ddlCountry size=1 name=country_origin onchange='storeValue(this)
Style="z-index: 130; left: 416px; position: absolute; top: 328px">
<OPTION selected>Select
one</OPTION>
<OPTGROUP label="North American Countries">
<OPTION value="United States">United
States</OPTION>
<OPTION value=Canada>Canada</OPTIO
<OPTION value=Mexico>Mexico</OPTIO
</OPTGROUP>
</SELECT>...
The hidden text field is:
<input id="hdnCountry" style="z-index: 131; left: 288px; position: absolute; top: 464px"
type="hidden" runat=server/>
The script that I'm running in the onchange event of the dropdownlist is:
<script type="text/javascript">
function storeValue(what)
{
document.getElmentById('hd
}
</script>
When I select a value from the dropdownlist, I get the following error in the
Java script: Microsoft JScript runtime error: Object doesn't support this property or method
Much thanks to anyone who can help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
change this:
document.getElementById('h dnCountry' ).value = what.value
to this:
document.getElementById('h dnCountry' ).value = what.options[what.selected Index].val ue
document.getElementById('h
to this:
document.getElementById('h
@basicinstinct:
The issue is the typo on document.getElementById.
dawesley mistyped it as:
document.getElmentById
what.value will work fine.
The issue is the typo on document.getElementById.
dawesley mistyped it as:
document.getElmentById
what.value will work fine.
>>I can't use 'runat=server' on the dropdownlist because it contains literals
and Microsoft won't accept them
what do you mean? all the values seem to be acceptable in a dropdownlist too
anyway .. for getting values of this at the server, you do not need to store it in hidden field and then access it .. you can gve this a try on the server side code
request.form("ddlCountry")
or request("dllCountry") ..
this should give you the last selected value in the HTML control ..
Rejo
and Microsoft won't accept them
what do you mean? all the values seem to be acceptable in a dropdownlist too
anyway .. for getting values of this at the server, you do not need to store it in hidden field and then access it .. you can gve this a try on the server side code
request.form("ddlCountry")
or request("dllCountry") ..
this should give you the last selected value in the HTML control ..
Rejo
-LTCJ