Andreas
Andreas

Reputation: 301

Uncaught TypeError in Chrome and Safari when referencing the name of a dropdown in JavaScript

The following code only seems to work in IE. In Chrome or Safari, I get the following error:

The console error I get in Chrome is:

Uncaught TypeError: Property 'choosetext' of object # is not a function

Here's the code:

function LoadPageText(){
document.location.href = "editpage.asp?file="+document.form.file.value+"&text="+document.form['choosetext'](document.form['choosetext'].selectedIndex).value;
}

How do I resolve this error for Safari and Chrome?

Upvotes: 0

Views: 285

Answers (1)

iJade
iJade

Reputation: 23801

Try accessing values using element id

document.getElementById('ElementId').value

For drop down list

document.getElementById('dropdownId').selectedIndex

to get selected index

Upvotes: 1

Related Questions