Object expected

jws2bay
jws2bay used Ask the Experts™
on
I am working in a php/msql environment.  This is a 2 part question.  I have been trying to change the Select Content of a list/menu.  I keep having an error of " 'Options' is undefined" from the "new Options("","")" statement.  

I built up a test page and now I am having an Object expected error from the call of my function.  

First - what do I have wrong in my test page?

Second - why am I getting the "Options is undefined"?

my test page link is:

http://www.glassdivider.com/test.php

Thanks for the help
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You can enable the Javascript debugger in IE will help to stop at where the isssue is

i) Open IE
ii) Navigate to Tools
iii) Select "Internet Options"
iv) Select "Advance Tab"

v) Unde Browsing Category
Uncheck teh check box 'disable script Debugger" will help you at stop where the error in Jaavascript

In your case it's says "Update()" function not there

  <td><input type="button" name="button" id="button" value="Load" onclick="Update()" /></td>

Author

Commented:
santhimurthyd

Thank you for the advice.  I was able to see the problem.  I had the function inside the <style> tage, so it wasn't being seen.  I knew it was something obvious.  Now I'm see the original problem.  

When I run the script now I'm getting the "Options is undefined from the  
new Options('' '','' '')   This is why I built the test page.

Any ideas on this problem?
It's Good you catch the eye opener teh issue is placing the Javascript insite the Style Tag.

Change the Javascritp with the below syntax will help you to add new options

<script type="text/javascript">

function Update(){
var select = document.getElementById("mid_shelf");
select.options[select.options.length] = new Option("No    Inner Shelf", "0");
select.options[select.options.length] = new Option("11         Inner Shelf", "0");
select.options[select.options.length] = new Option("17    Inner Shelf", "0");
select.options[select.options.length] = new Option("21    Inner Shelf", "0");
}
</script>

Author

Commented:
santhimurthyd

That works.  I've impliment the same function in my real page and it appears to work fine.  

Thanks for the help

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial