Click to See Complete Forum and Search --> : Picture problem....


Makaveli.2003
02-02-2003, 08:37 AM
I am having 1 problem - which is that all the different drop down menu's will have different pictures. So each section will have a different set of pictures, at the moment they all share the same pictures, which I dnt want. Is it possible for each drop down menu to have its own pictures section? (Iv posted the code below)

I would have thought putting in a:

var ImagesInList = new Array(10,4,1,11,9,6,7,7,6,4,5,3,2); // for example first select has 10 options

for the images and adding:

//create a new 0 array to hold the img source list
imglist = new BuildZeroArray(ImagesInList[13])
imglist[12][0] = new Image
imglist[12][0].src = "C:\My Documents\My Pictures\iceberg.jpg"
imglist[12][1] = new Image
imglist[12][1].src = "moon.gif"
imglist[12][2] = new Image
imglist[12][2].src = "storytellinglogo-2.jpg"

for each differnce option would have done the trick, iv experimented and it does seem to work, could ne1 help

gil davis
02-02-2003, 08:44 AM
Originally posted by Makaveli.2003
imglist[12][0] = new ImageShould be:

imglist[12][0] = new Image()

Makaveli.2003
02-02-2003, 09:53 AM
Originally posted by gil davis
Should be:

imglist[12][0] = new Image()
I edited my script but still cant get it to work, iv attached my edited script. Bascially I added these lines:

var ImagesInList = new Array(10,4,1,11,9,6,7,7,6,4,5,3,2); // for example first select has 10 options

and:

//create a new 0 array to hold the img source list
imglist[0] = new BuildZeroArray(ImagesInList[0])
imglist[0][0] = new Image ()
imglist[0][0].src = "C:\My Documents\My Pictures\iceberg.jpg"
imglist[0][1] = new Image ()
imglist[0][1].src = "moon.gif"
imglist[0][2] = new Image ()
imglist[0][2].src = "storytellinglogo-2.jpg"
imglist[0][3] = new Image ()
imglist[0][3].src = "soldi150.gif"
imglist[0][4] = new Image ()
imglist[0][4].src = "C:\My Documents\My Pictures\iceberg.jpg"
imglist[0][5] = new Image ()
imglist[0][5].src = "moon.gif"
imglist[0][6] = new Image ()
imglist[0][6].src = "storytellinglogo-2.jpg"
imglist[0][7] = new Image ()
imglist[0][7].src = "soldi150.gif"
imglist[0][8] = new Image ()
imglist[0][8].src = "C:\My Documents\My Pictures\iceberg.jpg"
imglist[0][9] = new Image ()
imglist[0][9].src = "moon.gif"
imglist[0][10] = new Image ()
imglist[0][10].src = "storytellinglogo-2.jpg"

//create a new 0 array to hold the img source list
imglist[1] = new BuildZeroArray(ImagesInList[1])
imglist[1][0] = new Image ()
imglist[1][0].src = "C:\My Documents\My Pictures\iceberg.jpg"
imglist[1][1] = new Image ()
imglist[1][1].src = "moon.gif"
imglist[1][2] = new Image ()
imglist[1][2].src = "storytellinglogo-2.jpg"
imglist[1][3] = new Image ()
imglist[1][3].src = "soldi150.gif"
imglist[1][4] = new Image ()
imglist[1][4].src = "C:\My Documents\My Pictures\iceberg.jpg"

For ^ each down down menu. Can ne1 see where im goin wrong?

gil davis
02-03-2003, 05:41 AM
There is not supposed to be a space between "Image" and "()".

khalidali63
02-03-2003, 07:38 AM
Originally posted by gil davis
There is not supposed to be a space between "Image" and "()".

????

white space between the constructor name and parenthesis may not look good but it does not have any bearing on the code to be wrong.
:D
cheers

Khalid

gil davis
02-03-2003, 08:29 AM
Well, after some experimentation, all three ways seem to work in IE 5.5 and NS 4.8. So, I don't know what is wrong.

Makaveli.2003
02-03-2003, 09:02 AM
I took out the spaces and it still dont work, theres got to be sum1 out ther that can help! :( :(

gil davis
02-03-2003, 09:05 AM
After further examination, your function updateRow() does not get the right source for the image.function updateRow(rownum){
var exeLine='ProdSubscript=document.ordform.prodchosen'+rownum+'.selectedIndex'
eval(exeLine)
eval('document.ordform.prod'+rownum+'.src = imglist[ProdSubscript].src')
ordData[rownum].prodsub=ProdSubscript
var exeLine='tempqty=document.ordform.qty'+rownum+'.value'
eval(exeLine)
ordData[rownum].qty=tempqty-0 //-- Gets unit price from the product price
ordData[rownum].unitprice=prodlist[rownum-1][ProdSubscript].unitprice
ordData[rownum].extprice=(ordData[rownum].qty)*ordData[rownum].unitprice
var exeLine='document.ordform.unitprice'+rownum+'.value=currency(ordData['+rownum+'].unitprice,10)'
eval (exeLine)
var exeLine='document.ordform.extprice'+rownum+'.value=currency(ordData['+rownum+'].extprice,10)'
eval(exeLine)
updateTotals()
}I hate the EVAL statement. Try this:

function updateRow(rownum) {
ProdSubscript = document.ordform["prodchosen" + rownum].selectedIndex;
document.ordform["prod" + rownum].src = imglist[rownum - 1][ProdSubscript].src;
ordData[rownum].prodsub = ProdSubscript;
tempqty = document.ordform["qty" + rownum].value;
ordData[rownum].qty = tempqty - 0;
ordData[rownum].unitprice = prodlist[rownum-1][ProdSubscript].unitprice;
ordData[rownum].extprice = (ordData[rownum].qty) * ordData[rownum].unitprice;
document.ordform["unitprice" + rownum].value = currency(ordData[rownum].unitprice, 10);
document.ordform["extprice" + rownum].value = currency(ordData[rownum].extprice, 10);
updateTotals();
}

Also, you should establish the imglist array by adding:

var imglist = new Array();

before you start loading the array. NS 4 fails there. NS 4 also does not like "c:\..." for URLs.

In case I forget something else, I've attached your file with all my changes. I clobbered the comments, you might want to put them back...

Makaveli.2003
02-03-2003, 09:52 AM
THANK YOU VERY MUCH that worked perfect gil davis, I have 1 more little problem - which is how would I change the quantity section into a drop down menu as at the moment it is not validated e.g. if the user puts in a letter there is no error message. Do u know how I cud change that so it was a scroll bar instead? Thanx again 4 ur time n effort!

Makaveli.2003
02-03-2003, 05:22 PM
I found a problem with that script, when I reset the the images dont go to the default settings, thye mess up, may be you could take a look gil davis, and tell me what needs doing, plz. I need this script to work in netscape, that was the main browser it will be run in, how would I change that? Plz cud u help me with this, thank you.

gil davis
02-03-2003, 07:55 PM
when I reset the the images dont go to the default settingsReset what?

Post your current file.

Makaveli.2003
02-04-2003, 02:27 AM
Originally posted by gil davis
Reset what?

Post your current file.
Well, wen u select a few options from the drop down menu (from any of the menus) and then select the reset butoon at the bottom of the script the pictures dont reset, they either stay at the picture last selected or go to X's with no image in. Try puting some of your images in on ur hard disk and test it, ull see what I mean. Also how do I get it to work in Netscape?? :confused:

gil davis
02-04-2003, 06:15 AM
I had to fix rBtn().

Makaveli.2003
02-04-2003, 08:53 AM
Originally posted by gil davis
I had to fix rBtn().

Worked perfect, xcept in Netscape, I got a error message, but it did work fine, do u know y i got a error message tho? And can u help put in the drop down menu for the qty instead of the user havin to type it in, as when a letter is typed in it doesnt wrk, it wud help/save time validating. Jus need the qty dorp down menu to b set as 0 as default - so if the user change it the price of the product still comes up under "unit price" (so user can view it) but the "ext price" stays at zero, but if user changes the qty drop down menu to watever they require the ext price updates as normal. Thank You 4 ur help it is much appreciated!

gil davis
02-04-2003, 09:17 AM
What version of Netscape? It works fine in NS 4.8. What is ther error message?

If you don't know how to add a drop-down box instead of a text box, then you need to take an HTML tutorial. You could try starting a new post on the HTML forum - maybe someone there will help you. When you set the text box to an initial value (value="0"), then if you reset the form, the quantity will reset to 0 automatically.

Or, you could find a JavaScript tutorial on form validation and do it the right way. It's not that hard.

BTW, you really should get rid of all that EVAL crap. It's too hard to maintain, and it's almost always longer than any other method.

Makaveli.2003
02-04-2003, 09:24 AM
Originally posted by gil davis
What version of Netscape? It works fine in NS 4.8. What is ther error message?

If you don't know how to add a drop-down box instead of a text box, then you need to take an HTML tutorial. You could try starting a new post on the HTML forum - maybe someone there will help you. When you set the text box to an initial value (value="0"), then if you reset the form, the quantity will reset to 0 automatically.

Or, you could find a JavaScript tutorial on form validation and do it the right way. It's not that hard.

BTW, you really should get rid of all that EVAL crap. It's too hard to maintain, and it's almost always longer than any other method.

I was using Netscape 4.7, but I jus tried it again and seems to be running fine. Ill look up the validation of javascript I think it will b better. As you have added a few bits to the code, could u jus add comments as im not sure what everything does. Apart from that thank tou very much 4 all ur help!! :) gil davis 4 president!! lol :)