Posts: 290134 Topics: 12047 LOGIN

Home >> Computers Hardware&Software >> Javascript question

23.02.2007, 12:03 quote

Anonymous

I am not very fond of Javascript as it is not documented properly and it is some sort of pseudo programming language.....

Maybe someone of you has an idea......

I am trying to display the picture description to every user picture inside of a div tag.

If someone clicks through the pictures with the previous and next button, I want to hide all div tags but the one that corresponds to the selected one.

The drop down list displays the number of the images....

This number is also used for naming the div tags.

But how do you reference variable names that are generated dynamically?

The layer is called desc+number = desc0, desc1, desc2....depending on how many user pictures there are.

Art:
function changeImage()
{
        var list = document.getElementById('optionlist');
        document.mainimage.src = list.options[list.selectedIndex].value;

//      var anzahl = list.options.length;

//      for (var x = 1; x < anzahl; x++){

//              if (x==list.options[list.selectedIndex]){
//              window["desc" + x].style.display='inline';
//              }

//              else {
//              window["desc" + x].style.display='none';
//              }
//      }

//      desc.style.display = 'none';

}


I am not sure whether you use the window method for that or not....

Rolling Eyes

 

23.02.2007, 13:38 quote

pirakkanaama2
pirakkanaama2 Joined: 30 Dec 2006 Posts: 1889 Location: United Kingdom, England, Leicestershire
View user's profile Visit poster's website

i know nothing about this, but i think you are AMAZINGLY smart for all what you done
_________________

 

23.02.2007, 13:47 quote

kebabman
kebabman Joined: 03 Jan 2007 Posts: 931 Location: United Kingdom, England, Lancashire
View user's profile Visit poster's website

god wrote:
I am not very fond of Javascript as it is not documented properly and it is some sort of pseudo programming language.....

Maybe someone of you has an idea......

I am trying to display the picture description to every user picture inside of a div tag.

If someone clicks through the pictures with the previous and next button, I want to hide all div tags but the one that corresponds to the selected one.

The drop down list displays the number of the images....

This number is also used for naming the div tags.

But how do you reference variable names that are generated dynamically?

The layer is called desc+number = desc0, desc1, desc2....depending on how many user pictures there are.

Art:
function changeImage()
{
        var list = document.getElementById('optionlist');
        document.mainimage.src = list.options[list.selectedIndex].value;

//      var anzahl = list.options.length;

//      for (var x = 1; x < anzahl; x++){

//              if (x==list.options[list.selectedIndex]){
//              window["desc" + x].style.display='inline';
//              }

//              else {
//              window["desc" + x].style.display='none';
//              }
//      }

//      desc.style.display = 'none';

}


I am not sure whether you use the window method for that or not....

Rolling Eyes


Which lines exactly are you having trouble with and why, ie, what is your desired output and what is happening, it's difficult to decipher from what you have put, I have hardly done any javacript but I am a competent coder so should be able to help with a bit more detail as it sounds like a fairly generic problem.
_________________

 

23.02.2007, 16:44 quote

Anonymous

meh

My brain

 

23.02.2007, 17:40 quote

toby

It is maybe a general problem/question.

You have variables that you can use in javascript in order to access the components such as a combobox in order to fire up some events when something happens or in order to find out which selection has been made.

When you click through the pictures on someones profile with the previous and next button, or if you use the combobox to directly jump to a particular picture, a javascript method is called that will replace the image with the selected one.

Now, I want to additionally, not only swap the user picture, but also display some additional text.

In order to do that I print all texts already at the beginning, but I just make them invisible. All those texts are surrounded by <div> tags and have an id - which are called desc0..desc{number of the last picture}.

So all the text is already on the page, but made invisible.

When someone now selects picture 2, the text for picture 2 should be displayed....this means all div elements need to stay invisible and the attribute of the correct div elements needs to be made visible.

If you then select picture 3, all <div> elements apart from desc3 need to be made invisible.

As the number of pictures are dynamic, the javascript needs to dynamically hide and show the div elements.

The name of the div elements can be built inside the javascript method it is just the "desc" string appended with the number of the image.

However, then you only have a string - but I need a reference to the component with that id....so basically it you receive a simple "String" that is the name of the method you want to call.

In real java you would do something like class.forName("com.my.funny.class"), and then you could call a method on it.

I dont know who to do that in Javascript though....it is not even a real class....

 

29.04.2007, 02:13 quote

xoid
xoid Joined: 20 Apr 2007 Posts: 3 Location: United Kingdom, England, Oxfordshire
View user's profile Visit poster's website
 

29.04.2007, 08:16 quote

aDecentGuy
aDecentGuy Joined: 27 Apr 2007 Posts: 94 Location: United Kingdom, England, Cambridgeshire
View user's profile Visit poster's website

xoid wrote:
What is not referenced ?

http://w3schools.com/jsref/default.asp

http://developer.mozilla.org/en/docs/About_JavaScript

http://jibbering.com/faq/

(ever heard of google?)


Being sarcastic towards the creator of FlirtBox is a tad silly my friend
_________________
Weedman

 
 
Jump to:

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum