Back To Start Of Archive
Taken From The Forum: Anything Goes
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:06
another one for the JavaScript gurus
Poster: wkilc
Dated: Saturday February 20 2010 - 17:15:43 GMT
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:
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; }
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:
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; }
if (document.Simple.Color.options[q].value == document.Restored.Color.value)
{ document.Simple.Color.options[q].checked = true; break; }
Thanks.
~Wayne
Re: another one for the JavaScript gurus
Poster: wkilc
Dated: Saturday February 20 2010 - 18:46:46 GMT
GOT IT!
Code:
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; }
if (document.Simple.Colors[q].value == document.Restored.Colors.value)
{ document.Simple.Colors[q].checked = true; break; }
Thanks anyway!
~Wayne