/    Sign up×
Community /Pin to ProfileBookmark

Browser Incompatabilities…

G’Day,

I’ve been writing some fairly basic JavaScripts revolving around selections from a combo box. They work perfectly fine for me (using Firefox), but others have told me they had some problems.

One of those problems is with a combo box which changes the contents of another combo box. The steps are to set the length to 1 (ie only leave the default option that is used by all) and add x new options. An example is below:

[code=php]<!–
function updateSelection(FormData)
{
var selection = FormData.recipes.value;
if (selection == “gustRec”)
{
FormData.name.value = “gustRec”;
FormData.step.length = “1”;
FormData.step.options[1] = new Option(“gustRec_1”, “gustRec_1”);
FormData.step.options[2] = new Option(“gustRec_2”, “gustRec_2”);
FormData.step.options[3] = new Option(“gustRec_3”, “gustRec_3”);
FormData.oper.value = “No Step”;
FormData.conf.value = “None Selected”;
FormData.pipe.value = “”;
FormData.size.value = “”;
FormData.snum.value = “0”;
FormData.dels.checked = false;
FormData.delr.checked = false;
}
}
// –>[/code]

On my system, this works fine, however a Mac user told me that if they, say, select one with seven options followed by another with three, then they get the three new options, followed by the last four of the old ones. I saw the same effect when I took out the `FormData.step.length = “1”;’ line, so I am assuming that this line is not compatable for some reason.

My second problem is that, apparently, none of the combo boxes ever change anything for Internet Explorer users. The code is basically the same for all the functions (including the example above), but most of them only change the value of a few text boxes. Is there some oddity with IE whereby it cannot use a script like the one above?

Thanks for any advice!

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@KorApr 27.2005 — FormData.name.value looks incorrect to me, as [b]name[/b] is a reserved javascript word, thus it can not be used as a variable/function name.

FormData.step.length = "1"; looks also incorrect, as [b]lenght[/b] is an atribute who need numbers as values, not strings

What suppose to do your code?
Copy linkTweet thisAlerts:
@scragarApr 27.2005 — you want to set the length of the options array to 1, not an object.
Copy linkTweet thisAlerts:
@Matthew_PercivaauthorApr 27.2005 — I made a few changes, and managed to get things to work. I fixed the first problem by looping through the array and setting each to null, until there was only one left. The problem with the latter was that I had not set the form up correctly: other browsers seemed able to work it out themselves, but IE could not for whatever reason.

The script takes input from a combo box, then replaces the values in different elements on a form. I've not seemed to have any problems with the text box named name', though I did have trouble when I called one enum' (obviously because this is a reserved word - I just renamed it to fix that problem).

The script also adds/removes items from a second combo box, and this is what I want to expand upon next. I have added optgroups to sort the second combo box, but I want to have an option to enable/disable different groups. I know that in the html I can do optgroup label="blah" disabled' for this effect (though it doesn't seem to work in IE again - is this just me, or is there a problem with IE and disabling optgroups?). I want to add this to my JavaScript, but have not been able to find how to access optgroups here. I assume it's document.form.select.foo.disabled = true', but I cannot find what foo is. Any suggestions?

Thanks!
×

Success!

Help @Matthew_Perciva spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...