please nobody who can help me with this simple script?

Discussion in 'Javascript' started by Lodewijk van Haringhal, Sep 5, 2003.

  1. I'am new with javascritping not with programming. Is there nobody who can
    help me with ths simple promblem? :) Please, please give me a hint.

    Please help me with this script. I have two lists in my form. One to choose
    a directory and one to choose a picture. The script bellow works perfect
    without the directory choose function.
    I tried to make the directory choose function myself but I did not succeed.
    I think I made a mistake here: document.pic.src = picLocation[theChoice2] +
    picFile[theChoice];

    Please give me a hint or a solution.
    Thanks!

    the script:

    function changePicture()
    {
    var picFile = new Array ("empty.gif", "01vk.gif", "02vk.gif", "03vk.gif",
    "04vk.gif", "05vk.gif", "06vk.gif", "07vk.gif",
    "08vk.gif", "09vk.gif", "10vk.gif"); //change filename

    var picLocation = new Array ("", "pic/Gif thumbs vk/", "pic2/Gif thumbs
    vk/", "pic3/Gif thumbs vk/",
    "pic4/Gif thumbs vk/", "pic5/Gif thumbs vk/");
    //change filelocation

    /* txt addition
    var picText = new Array ("", "Kaart 1", "Kaart 2", "Kaart 3", "Kaart 4",
    "Kaart 5", "Kaart 6", "Kaart 7", "Kaart 8", "Kaart
    9", "Kaart 10");

    var selection = document.DropPicture.Picture.selectedIndex;
    var selection2 = document.DropPicture.Directory.selectedIndex;
    var theChoice = document.DropPicture.Picture.options[selection].value;
    var theChoice2 = document.DropPicture.Directory.options[selection].value;
    document.pic.src = picLocation[theChoice2] + picFile[theChoice];
    document.all.picWords.innerText = picText[theChoice];

    }
    </SCRIPT>
     
    Lodewijk van Haringhal, Sep 5, 2003
    #1
    1. Advertising

  2. Lodewijk van Haringhal

    lallous Guest

    Hello

    Try:
    document.pic.src = picLocation[selection2] + picFile[selection];
    Instead of:
    document.pic.src = picLocation[theChoice2] + picFile[theChoice];

    What you initially wrote will only work if theChoice2/theChoice will contain
    numeric values who are ranged from 0 to picLocation.length-1

    You cannot access 'picFile' with a non numeric index.

    hope that helps
    Elias
    "Lodewijk van Haringhal" <> wrote in message
    news:3f58ab34$0$49101$4all.nl...
    > I'am new with javascritping not with programming. Is there nobody who can
    > help me with ths simple promblem? :) Please, please give me a hint.
    >
    > Please help me with this script. I have two lists in my form. One to

    choose
    > a directory and one to choose a picture. The script bellow works perfect
    > without the directory choose function.
    > I tried to make the directory choose function myself but I did not

    succeed.
    > I think I made a mistake here: document.pic.src = picLocation[theChoice2]

    +
    > picFile[theChoice];
    >
    > Please give me a hint or a solution.
    > Thanks!
    >
    > the script:
    >
    > function changePicture()
    > {
    > var picFile = new Array ("empty.gif", "01vk.gif", "02vk.gif", "03vk.gif",
    > "04vk.gif", "05vk.gif", "06vk.gif", "07vk.gif",
    > "08vk.gif", "09vk.gif", "10vk.gif"); //change filename
    >
    > var picLocation = new Array ("", "pic/Gif thumbs vk/", "pic2/Gif thumbs
    > vk/", "pic3/Gif thumbs vk/",
    > "pic4/Gif thumbs vk/", "pic5/Gif thumbs vk/");
    > //change filelocation
    >
    > /* txt addition
    > var picText = new Array ("", "Kaart 1", "Kaart 2", "Kaart 3", "Kaart 4",
    > "Kaart 5", "Kaart 6", "Kaart 7", "Kaart 8",

    "Kaart
    > 9", "Kaart 10");
    >
    > var selection = document.DropPicture.Picture.selectedIndex;
    > var selection2 = document.DropPicture.Directory.selectedIndex;
    > var theChoice = document.DropPicture.Picture.options[selection].value;
    > var theChoice2 = document.DropPicture.Directory.options[selection].value;
    > document.pic.src = picLocation[theChoice2] + picFile[theChoice];
    > document.all.picWords.innerText = picText[theChoice];
    >
    > }
    > </SCRIPT>
    >
    >
    >
    >
     
    lallous, Sep 5, 2003
    #2
    1. Advertising

  3. Hi Elias,

    Thanks this works fine but now my choice is limited to the ammount of
    entry's in the picLocation array. when there are 4 directories I can only
    choose 4 pictures?

    Can you help me with this?


    > Try:
    > document.pic.src = picLocation[selection2] + picFile[selection];
    > Instead of:
    > document.pic.src = picLocation[theChoice2] + picFile[theChoice];
    >
    > What you initially wrote will only work if theChoice2/theChoice will

    contain
    > numeric values who are ranged from 0 to picLocation.length-1
    >
    > You cannot access 'picFile' with a non numeric index.
    >
    > hope that helps
    > Elias
    > "Lodewijk van Haringhal" <> wrote in message
    > news:3f58ab34$0$49101$4all.nl...
    > > I'am new with javascritping not with programming. Is there nobody who

    can
    > > help me with ths simple promblem? :) Please, please give me a hint.
    > >
    > > Please help me with this script. I have two lists in my form. One to

    > choose
    > > a directory and one to choose a picture. The script bellow works perfect
    > > without the directory choose function.
    > > I tried to make the directory choose function myself but I did not

    > succeed.
    > > I think I made a mistake here: document.pic.src =

    picLocation[theChoice2]
    > +
    > > picFile[theChoice];
    > >
    > > Please give me a hint or a solution.
    > > Thanks!
    > >
    > > the script:
    > >
    > > function changePicture()
    > > {
    > > var picFile = new Array ("empty.gif", "01vk.gif", "02vk.gif",

    "03vk.gif",
    > > "04vk.gif", "05vk.gif", "06vk.gif", "07vk.gif",
    > > "08vk.gif", "09vk.gif", "10vk.gif"); //change filename
    > >
    > > var picLocation = new Array ("", "pic/Gif thumbs vk/", "pic2/Gif thumbs
    > > vk/", "pic3/Gif thumbs vk/",
    > > "pic4/Gif thumbs vk/", "pic5/Gif thumbs vk/");
    > > //change filelocation
    > >
    > > /* txt addition
    > > var picText = new Array ("", "Kaart 1", "Kaart 2", "Kaart 3", "Kaart 4",
    > > "Kaart 5", "Kaart 6", "Kaart 7", "Kaart 8",

    > "Kaart
    > > 9", "Kaart 10");
    > >
    > > var selection = document.DropPicture.Picture.selectedIndex;
    > > var selection2 = document.DropPicture.Directory.selectedIndex;
    > > var theChoice = document.DropPicture.Picture.options[selection].value;
    > > var theChoice2 =

    document.DropPicture.Directory.options[selection].value;
    > > document.pic.src = picLocation[theChoice2] + picFile[theChoice];
    > > document.all.picWords.innerText = picText[theChoice];
    > >
    > > }
    > > </SCRIPT>
    > >
    > >
    > >
    > >

    >
    >
     
    Lodewijk van Haringhal, Sep 5, 2003
    #3
  4. Lodewijk van Haringhal

    lallous Guest

    Hello Lodewijk,

    1)You can increase values in both arrays in a parallel manner
    2)in the location's listbox option values you set values that are in
    the range of its array.
    <option value="0">loc1</option>
    etc...
    all the values returned now will be from 0 to arraySize even if there
    are more items in the listbox than in the array.

    Elias
    "Lodewijk van Haringhal" <> wrote in message news:<3f58b3c1$0$49117$4all.nl>...
    > Hi Elias,
    >
    > Thanks this works fine but now my choice is limited to the ammount of
    > entry's in the picLocation array. when there are 4 directories I can only
    > choose 4 pictures?
    >
    > Can you help me with this?
    >
     
    lallous, Sep 6, 2003
    #4
    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. David C
    Replies:
    2
    Views:
    311
    John Saunders
    Dec 17, 2004
  2. G Dean Blake

    Bet nobody is smart enough to solve this!!

    G Dean Blake, Jan 15, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    404
    G Dean Blake
    Jan 15, 2005
  3. KK
    Replies:
    2
    Views:
    649
    Big Brian
    Oct 14, 2003
  4. André
    Replies:
    0
    Views:
    333
    André
    Jun 27, 2006
  5. André

    is there really nobody who can solve this?

    André, Jun 27, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    120
    André
    Jun 27, 2006
Loading...

Share This Page