PDA

View Full Version : Form Dependency Script



KyleT4L
08-19-2008, 02:39 AM
Hello, all!

This is the script: http://www.dynamicdrive.com/dynamicindex16/formdependency.htm

Okay, this problem could either be javascript related or HTML related. Maybe a bit of both.

I am using the form dependancy script created by Twey, and it works great. Only problem is, I can't seem to get the SELECTED option working for dropdown menus, which is kind of annoying.

HTML can be found here: www.training4life.org/file.htm

For example, if you click BLS at the top, new dropdown menus appear.

But they're blank.

You have to physically click them and select an item. I would rather that a 'standard' item be automatically selected when they appear.

Like a regular dropdown menu WITHOUT the javascript, you can use the SELECTED option to show which item will show up first on the dropdown (without clicking it), or otherwise the first item will appear first.

For some reason with this script that is no longer true.

Anyone (Twey perhaps?) have any ideas?

Twey
08-19-2008, 06:14 PM
Hm... in what browser is this occurring?

KyleT4L
08-19-2008, 10:27 PM
Hello, sir!

Internet Explorer. The newest version, I'd wager, since I'm using Vista. Not quite sure how to check version on Vista yet. Definitely internet explorer, though.

Twey
08-19-2008, 10:54 PM
Peculiar. The script does not explicitly reset the value of... ah!

Remove the two lines
if(typeof this.checked !== "undefined") this.checked = false;
else this.value = "";and see if this fixes your issue.

KyleT4L
08-20-2008, 04:46 AM
Thank you. I do believe that worked, sir.

KyleT4L
08-26-2008, 04:53 PM
Of course, now something new arises--isn't that always the way?

It seems like I'll have to deal without the options being selected.

If you enjoy puzzles you may enjoy this.

When I remove the lines you outlined, my problem with the standard selections go away. But, if I send the information out as an e-mail (the point of the form) every option is populated into the e-mail, as opposed to just the one selected.

It's like a catch 22.

I thought I'd share that with you, in case you had any thoughts.

Twey
08-26-2008, 07:57 PM
Where those two lines were, try inserting the single line:
this.disabled = true;Also, to make sure they don't stay disabled, find these lines:
var showEl = function() {
this.style.display = "";and insert after them:
this.disabled = false;

KyleT4L
08-27-2008, 04:05 PM
Thank you for continuing to help.

I did as you instructed, and as you can see from the link above (http://www.training4life.org/file.htm), now everything is automatically selected.

Did I do something wrong somehow?

KyleT4L
09-05-2008, 03:31 PM
Is there nothing else that can be done?

Twey
09-06-2008, 09:28 AM
You broke it by inserting the else this.value = "";from before as well. Remove that.

KyleT4L
09-08-2008, 03:32 PM
You, sir, are a champion.

Thank you for all your expertise and patience.

- Kyle