harsha500
harsha500

Reputation: 5

drop down list onclick change value of input not working on chrome or opera

i have drop down item list. when i select an item. it should update input box on item prices. but it works perfectly on firefox and IE 9. dont work chrome or opera. anybody have an idea ?

<option onclick="javascript:document.getElementById('price').value='$0.00'"/>   


<input type="text" name="price" id="price" />

Upvotes: 0

Views: 1999

Answers (1)

Michael Aaron Safyan
Michael Aaron Safyan

Reputation: 95519

These <option> elements in your code should be wrapped in a <select> element. When the selection changes, it results in a change event getting triggered. You should update the UI by handling the change event (rather than a click on a particular element). You should probably also factor out your handler function into an external JavaScript file (and put it into a named function) rather than defining the handler inline in the HTML file as you are doing with this piece of example code.

Upvotes: 1

Related Questions