Shorten script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Francois

    Shorten script

    Hi,

    This is probably a very easy question...but I just don't know the answer...

    I want to shorten this script:

    document.formul ier.form_o_stoe l1.checked = false;
    document.formul ier.form_o_stoe l2.checked = false;
    document.formul ier.form_o_stoe l3.checked = false;
    document.formul ier.form_o_stoe l4.checked = false;
    document.formul ier.form_o_stoe l5.checked = false;
    document.formul ier.form_o_stoe l6.checked = false;
    document.formul ier.form_o_stoe l7.checked = false;
    document.formul ier.form_o_stoe l8.checked = false;
    document.formul ier.form_o_stoe l9.checked = false;
    document.formul ier.form_o_stoe l10.checked = false;

    I think it should be possible with something like

    for (i=0; i<10; i++) {
    document.formul ier.form_o_stoe l&[i].checked = false;
    }

    Please take a minute to help me with this...
    Thanks!


  • Vjekoslav Begovic

    #2
    Re: Shorten script

    "Francois" <francois.sachs @gidesign.nl> wrote in message
    news:3f9e5b93$0 $257$19deed1b@n ews.inter.NL.ne t...[color=blue]
    > Hi,
    >
    > This is probably a very easy question...but I just don't know the[/color]
    answer...[color=blue]
    >
    > I want to shorten this script:
    >
    > document.formul ier.form_o_stoe l1.checked = false;
    > document.formul ier.form_o_stoe l2.checked = false;
    > document.formul ier.form_o_stoe l3.checked = false;
    > document.formul ier.form_o_stoe l4.checked = false;
    > document.formul ier.form_o_stoe l5.checked = false;
    > document.formul ier.form_o_stoe l6.checked = false;
    > document.formul ier.form_o_stoe l7.checked = false;
    > document.formul ier.form_o_stoe l8.checked = false;
    > document.formul ier.form_o_stoe l9.checked = false;
    > document.formul ier.form_o_stoe l10.checked = false;
    >
    > I think it should be possible with something like
    >
    > for (i=0; i<10; i++) {
    > document.formul ier.form_o_stoe l&[i].checked = false;
    > }
    >[/color]

    for (var i=1; i<=10; i++) {
    document.forms["formulier"].elements["form_o_stoel"+ i].checked = false;
    }


    Comment

    • Fred Serry

      #3
      Re: Shorten script


      "Francois" <francois.sachs @gidesign.nl> schreef in bericht
      news:3f9e5b93$0 $257$19deed1b@n ews.inter.NL.ne t...[color=blue]
      > Hi,
      >
      > This is probably a very easy question...but I just don't know the[/color]
      answer...[color=blue]
      >
      > I want to shorten this script:
      >
      > document.formul ier.form_o_stoe l1.checked = false;
      > document.formul ier.form_o_stoe l2.checked = false;
      > document.formul ier.form_o_stoe l3.checked = false;
      > document.formul ier.form_o_stoe l4.checked = false;
      > document.formul ier.form_o_stoe l5.checked = false;
      > document.formul ier.form_o_stoe l6.checked = false;
      > document.formul ier.form_o_stoe l7.checked = false;
      > document.formul ier.form_o_stoe l8.checked = false;
      > document.formul ier.form_o_stoe l9.checked = false;
      > document.formul ier.form_o_stoe l10.checked = false;
      >
      > I think it should be possible with something like
      >
      > for (i=0; i<10; i++) {
      > document.formul ier.form_o_stoe l&[i].checked = false;
      > }
      >
      > Please take a minute to help me with this...
      > Thanks!
      >
      >[/color]

      Hi,

      for (i=1; i<11; i++) {
      document.formul ier.elements["form_o_sto el" + i].checked = false;
      }

      Fred


      Comment

      Working...