another one for the JavaScript gurus

A forum for, well, anything really.
Gripes, moans, ideas or just general chit chat. EXCEPT SPAM!!! - Don't just register to post here - IT WILL GET DELETED!!!
Post Reply
wkilc
Super Advanced
Super Advanced
Posts: 60
Joined: Fri Sep 26, 2003 9:28 pm

another one for the JavaScript gurus

Post by wkilc »

Hi all,

Once again, please forgive me for asking this here... please know that I am a long-time member of the Milonic family (I own a half dozen licenses), and I now a lot of knowledgeable people frequent the Milonic boards.

This does have something to do with the Milonic menu, as the form in question is powered by the menu to populate some very long "virtual" pull-down menus. (Andy assisted me with this a few years back.)

Anyway, I have a form which can be saved (Perl script that saves to a database) and later edited.

When restoring data to the form, text fields are easy.

There is a simple (existing) JavaScript which restores an option that was selected from a pull-down (select one) menu:

Code: Select all

for (var q=0;q<document.Simple.Color.options.length;q++) {
  if (document.Simple.Color.options[q].value == document.Restored.Color.value)
   { document.Simple.Color.options[q].selected = true; break; }
I'm trying to make it work to restore a value to a radio button as well, by changing "selected" to "checked"... but no luck:

Code: Select all

for (var q=0;q<document.Simple.Color.options.length;q++) {
  if (document.Simple.Color.options[q].value == document.Restored.Color.value)
   { document.Simple.Color.options[q].checked = true; break; }
Thanks.

~Wayne
wkilc
Super Advanced
Super Advanced
Posts: 60
Joined: Fri Sep 26, 2003 9:28 pm

Re: another one for the JavaScript gurus

Post by wkilc »

GOT IT! :D

Code: Select all

  for (var q=0;q<document.Simple.Colors.length;q++) {
	if (document.Simple.Colors[q].value == document.Restored.Colors.value) 
    { document.Simple.Colors[q].checked = true; break; } 
Thanks anyway!

~Wayne
Post Reply