Click to See Complete Forum and Search --> : Problem with List/Menu


rleffew1
08-13-2003, 09:14 PM
I have inherited a site using javascript and am trying to learn the language.

I have a problem I cant figure out.

On my page I have a form with a List/Menu inside of a form.

the value of the list box is a name that corresponds with a jpg in a defined directory and also corresponds with a html page in a defined directory.

When you click on the List/Menu in real time the corresponding image changes accordingly and when the image is clicked on the correct page opens.

But when I tried adding a new value to the Lis/Menu in development, in real time the image changes but html page does not. (Value of html remains contant)

I definitely added a jpg into the proper directory with the proper value name and also created a html page with the proper name.

All I can figure out is when I add in new values some type of index must be being kept but I cant figure out where.

Any suggestions?

Below is code from program:

<script language="JavaScript1.2" cyberversion="N1.2"><!--

function PreLoad() {
var doc=document;
if(doc.images){
if(!doc.newarray) doc.newarray=new Array();
var x,y=doc.newarray.length,a=PreLoad.arguments;
for(x=0; x<a.length; x++)
if (a[x].indexOf("#")!=0){
doc.newarray[y]=new Image; doc.newarray[y++].src=a[x];
}
}
}

function PreLoadAll() {
PreLoad('images/npabout.gif', 'images/npctcat.gif', 'images/npcontact.gif',
'images/npfloorplan.gif', 'images/npform.gif', 'images/nphelp.gif',
'images/npshoppinglist.gif', 'images/nptdcat.gif',
'images/thumbnails/CustomCabinets.jpg');
}

function changeReadout(newReadout)

{

// change image for nav readout

window.document.np.src = newReadout;

}

function changeProduct(selectedProduct)

{
if (selectedProduct == ""){
} else {
// changeout product image

var newSrc = "images/thumbnails/" + selectedProduct + ".jpg";
window.document.preview.src = newSrc;

// changeout product link address

var newPreviewLink = "catalog/" + selectedProduct + ".html";
window.document.links[16].href = newPreviewLink;
}
}

function OpenList()
{
window.open('catalog/preview.html','ListWindow','width=400,height=500,direct
ories=no,location=no,menubar=no,scrollbars=yes,status=yes,toolbar=no,resizab
le=no,status=no,titlebar=no');
}
-->
</script>

Thanks,

Bob Leffew

Fang
08-14-2003, 03:09 AM
Could you give us the url or full code, this snippet is not enough.

rleffew1
08-14-2003, 07:04 AM
This is the URL that works before I add anything to the List/Menu:

http://www.childtechnologies.com/catalog.html

This is the URL that i am using for testing that I added items to the List/Menu and now won't work.

http://www.childtechnologies.com/index2.html

Note: I have added all the additions to the List/Menu box. The only one I have a actual page and jpg set up for is Infant Loft. (Third down from top).

In catalog.html when I click on a product in the list a corresponding picture pops up to the right as does in index2.html.

When clicking on the picture in catalog.html it goes to the proper URL that corresponds with the List item and picture.

When clicking on the picture in index2.html the URL stays the same http://www.childtechnologies.com/catalog/AquariumStand.html

Which is the default URL.

PLEASE HELP.

diamonds
08-14-2003, 01:44 PM
When I use it, it works(some images are un-available, though, but no errors are coming up!)

rleffew1
08-14-2003, 03:06 PM
I dont see how you can say its works. Yes there are some jpgs missing, but i mention that in the above posting.

The problem is in index2.html when clicking on the picture it only goes to one URL http://www.childtechnologies.com/catalog/AquariumStand.html
which is the default on the page.

If you look on this URL (Which is the one currently active and the page i am trying to change, when clicking on the picture it takes you to the correct URL that corresponds with the list item clicked in the List/Menu.

Please advise me if this in not working as i describe.

rleffew1
08-14-2003, 03:16 PM
Good URL:
http://www.childtechnologies.com/catalog.html

This is page I am trying to add new products to the list menu.

I have not put in all of the Jpegs and html pages associated with the menu into the new page I have created for testing purposes:

The page that doesnt work and has the products entered into the List/Menu is:

http://www.childtechnologies.com/index2.html

When you click on any picture in index2.html it take you to the following URL:

http://www.childtechnologies.com/index2.html

This is my problem.

It works fine in catalog.html

The pictures change fine in index2.html the URL doesnt seem to.

Thanks,

Bob

diamonds
08-14-2003, 04:09 PM
Lets see...
the function that changes the link destanation in the good file is what?
changeReadout() ?

diamonds
08-14-2003, 04:13 PM
I KNOW WHAT IS HAPPINING!!!
What i want you to do is go to your faulty page. (http://www.childtechnologies.com/index2.html)

Now, Select one of your prouducts.

Next, click the image next to the link called "Order Paper Catalog". This should take you to the product you selected.

Why this is happining is when you refer to the 16th link in your HTML, it is refering to that link, not the one in the image you want.

replace the "16" with another number: 15, like this:

function changeProduct(selectedProduct)

{
if (selectedProduct == ""){
} else {
// changeout product image

var newSrc = "images/thumbnails/" + selectedProduct + ".jpg";
window.document.preview.src = newSrc;

// changeout product link address

var newPreviewLink = "catalog/" + selectedProduct + ".html";
window.document.links[ 15 ].href = newPreviewLink;
}
}

Please remember javascript and many other languages start counting at 0. make sure that your first link is numbered zero before you start counting.

rleffew1
08-14-2003, 04:53 PM
I am not sure what you mean.

I changed the index to 15 as you suggested and it made no difference.

I am a Cobol / Visual Basic programmer so I understand indexes.

Sadly not experienced in Javascript.

Is there somewhere I could find information on this.

Could i call you?

Desparate.

Bob

diamonds
08-14-2003, 05:13 PM
Did you do what I told you to do?
Open your page, select an item, than move your mouse over ALL the links on your page. One of the ones towards the end should refer to the item you selected.

Tell me EXACTLY what you changed.
Did you add new links onto your page during the process?

Try changing it to 13...

rleffew1
08-14-2003, 05:38 PM
Thank you,

I finally figured out what you meant.

It was 14.

Thanks,

Bob