Shorten script

Discussion in 'Javascript' started by Francois, Oct 28, 2003.

  1. Francois

    Francois Guest

    Hi,

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

    I want to shorten this script:

    document.formulier.form_o_stoel1.checked = false;
    document.formulier.form_o_stoel2.checked = false;
    document.formulier.form_o_stoel3.checked = false;
    document.formulier.form_o_stoel4.checked = false;
    document.formulier.form_o_stoel5.checked = false;
    document.formulier.form_o_stoel6.checked = false;
    document.formulier.form_o_stoel7.checked = false;
    document.formulier.form_o_stoel8.checked = false;
    document.formulier.form_o_stoel9.checked = false;
    document.formulier.form_o_stoel10.checked = false;

    I think it should be possible with something like

    for (i=0; i<10; i++) {
    document.formulier.form_o_stoel&.checked = false;
    }

    Please take a minute to help me with this...
    Thanks!
     
    Francois, Oct 28, 2003
    #1
    1. Advertising

  2. "Francois" <> wrote in message
    news:3f9e5b93$0$257$...
    > Hi,
    >
    > This is probably a very easy question...but I just don't know the

    answer...
    >
    > I want to shorten this script:
    >
    > document.formulier.form_o_stoel1.checked = false;
    > document.formulier.form_o_stoel2.checked = false;
    > document.formulier.form_o_stoel3.checked = false;
    > document.formulier.form_o_stoel4.checked = false;
    > document.formulier.form_o_stoel5.checked = false;
    > document.formulier.form_o_stoel6.checked = false;
    > document.formulier.form_o_stoel7.checked = false;
    > document.formulier.form_o_stoel8.checked = false;
    > document.formulier.form_o_stoel9.checked = false;
    > document.formulier.form_o_stoel10.checked = false;
    >
    > I think it should be possible with something like
    >
    > for (i=0; i<10; i++) {
    > document.formulier.form_o_stoel&.checked = false;
    > }
    >


    for (var i=1; i<=10; i++) {
    document.forms["formulier"].elements["form_o_stoel"+i].checked = false;
    }
     
    Vjekoslav Begovic, Oct 28, 2003
    #2
    1. Advertising

  3. Francois

    Fred Serry Guest

    "Francois" <> schreef in bericht
    news:3f9e5b93$0$257$...
    > Hi,
    >
    > This is probably a very easy question...but I just don't know the

    answer...
    >
    > I want to shorten this script:
    >
    > document.formulier.form_o_stoel1.checked = false;
    > document.formulier.form_o_stoel2.checked = false;
    > document.formulier.form_o_stoel3.checked = false;
    > document.formulier.form_o_stoel4.checked = false;
    > document.formulier.form_o_stoel5.checked = false;
    > document.formulier.form_o_stoel6.checked = false;
    > document.formulier.form_o_stoel7.checked = false;
    > document.formulier.form_o_stoel8.checked = false;
    > document.formulier.form_o_stoel9.checked = false;
    > document.formulier.form_o_stoel10.checked = false;
    >
    > I think it should be possible with something like
    >
    > for (i=0; i<10; i++) {
    > document.formulier.form_o_stoel&.checked = false;
    > }
    >
    > Please take a minute to help me with this...
    > Thanks!
    >
    >


    Hi,

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

    Fred
     
    Fred Serry, Oct 28, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kenneth Keeley

    Shorten a SQL VarChar result.

    Kenneth Keeley, Oct 28, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    697
    Scott Mitchell [MVP]
    Oct 28, 2004
  2. =?Utf-8?B?V2ViIFJlc3BvbnNlIFRpbWU=?=

    How can I shorten this time?

    =?Utf-8?B?V2ViIFJlc3BvbnNlIFRpbWU=?=, Oct 28, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    347
    Scott Allen
    Oct 28, 2004
  3. Crispy
    Replies:
    3
    Views:
    683
    sinclar sodersas
    Jul 12, 2003
  4. Benjamin Rutt

    finding redundant #includes to shorten compile time

    Benjamin Rutt, Feb 5, 2004, in forum: C Programming
    Replies:
    15
    Views:
    1,030
    CBFalconer
    Feb 6, 2004
  5. ben
    Replies:
    8
    Views:
    393
Loading...

Share This Page