my dog learned polymorphism*
The moose likes HTML, CSS and JavaScript and the fly likes Function toggle does not work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Function toggle does not work" Watch "Function toggle does not work" New topic
Author

Function toggle does not work

dela cruz juan
Greenhorn

Joined: Nov 21, 2012
Posts: 13
Hi Java Script GURU's


I got this basic form that has a validation procedure when selecting on the 1st selection box the valid table should only appear. I got no problems when selecting "Homeroom" and "Sicience"
even if i change the selection on the two topics it shows the valid table but when I choose "Math", "laboratory", "Diff" and "others" the tables keep appending
downwards. Is there something missing on the scipt?

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60804
    
  65

Wow, that code has some problems. Firstly, why the call to eval()?

dela cruz juan wrote:Hi Java GURU's

This is JavaScript, not Java. Big difference.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
dela cruz juan
Greenhorn

Joined: Nov 21, 2012
Posts: 13
Firstly, why the call to eval()?

Really not sure cause I'm still trying hard to understand and learn about this,
I believe some of the items on the 1st selection box has a dependent items that should show on selection box of the hidden table,
really hard to explain but it goes something like this example

This is JavaScript, not Java. Big difference.

Sorry if I posted this in the wrong location,
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60804
    
  65

dela cruz juan wrote:
Firstly, why the call to eval()?

Really not sure cause I'm still trying hard to understand and learn about this,

Then why is it there? Did you write it? If so, why? If not, where did this code come from?

If this is code you found somewhere and are trying to use it to learn anything, then stop, delete it, and pretend you never saw it. It's awful.

This is JavaScript, not Java. Big difference.

Sorry if I posted this in the wrong location,

My point was that you asked for help from "Java Gurus" for a JavaScript problem. Java is not JavaScript. Do not confuse them.
dela cruz juan
Greenhorn

Joined: Nov 21, 2012
Posts: 13
If not, where did this code come from?

yes I did just copied that from some online resource
delete it, and pretend you never saw it. It's awful.

Just tried to delete the eval() line, the behavior just only becomes worst, all of the tables now show upon selecting
you asked for help from "Java Gurus" for a JavaScript problem. Java is not JavaScript. Do not confuse them.

Sorry if I mislead the readers, I just made the correction on the above now
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60804
    
  65

Of course itr's not going to work if you just delete a single statement. My point is that whatever that code is doing, it's poorly written and you just forget the whole example.

Now back up 57 steps or so and just tell us what you are trying to do and we can help you write code to do it without relying upon badly-written examples.
dela cruz juan
Greenhorn

Joined: Nov 21, 2012
Posts: 13
Thanks,

The form has a 1 table that is loaded by default, the table has a 1st selection box. If I select one item let say "Homerrom" the corresponding homeroom table should be loaded below,
if I change to select "science" then math table should disappear then science table should be loaded. My problem by now is if I select:



there tables just load and the form would never update if I select a new item on the 1st selection box
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60804
    
  65

OK, so you are just trying to hide and show elements based upon a selection? Easy. Especially if you take it one step at a time

What's the first thing you need to do?

OK, I'll help kick-start you by giving you the answer: you must establish an event handler for the change event for the select element. Give that a try and see if you can get an event handler to execute when the value of the select is changed.

Is there any reason that you cannot use jQuery for this? That will make everything much, much easier.
dela cruz juan
Greenhorn

Joined: Nov 21, 2012
Posts: 13
Thank you very much on your advises, I'm not familiar yet on Jquery but I'll give it a try on the kickstart that you've mentioned.
I'll keep you guys posted on the result.

thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Function toggle does not work
 
Similar Threads
Question on jQuery ajax functionality & troubleshooting called bean in JSF page
Redirecting a page
My (enabled) button works but if I test to renew my selection it won't get back to being disabled
communication between jsp and servlet
form does not validate in my selection box