SitePoint Sponsor

User Tag List

Results 1 to 13 of 13

Thread: Help plz

  1. #1
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile Help plz

    I need to label pictures using a case statement [SelectPeep(Persons)], is it possible to do it the way ive tried already or is there another approach to this ?

    var howMany = 5
    var url = new Array(howMany+1)
    url[0] = '01.jpg', SelectPeep(1), SelectPeep(2);
    url[1] = '02.jpg', SelectPeep(2);
    url[2] = '03.jpg', SelectPeep(4), SelectPeep(5);
    url[3] = '04.jpg', SelectPeep(5);
    url[4] = '05.jpg', SelectPeep(6);
    url[5] = '06.jpg', SelectPeep(7), SelectPeep(5), SelectPeep(2);;

    function SelectPeep(Persons)
    {
    switch (Persons)
    {
    case 1 : Persons = "name 1"; break;
    case 2 : Persons = "name 2"; break;
    case 3 : Persons = "name 3"; break;
    case 4 : Persons = "name 4"; break;
    case 5 : Persons = "name 5"; break;
    case 6 : Persons = "name 6"; break;
    case 7 : Persons = "name 7"; break;
    }
    document.title = Persons
    }

    Thanks for any help

  2. #2
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Will the picture/label combo be random?
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  3. #3
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    :)

    im notsure how to explain it, but it will need to be a random input.

    Basically, when i mouseover the pictures, it will tell me the people's names in the pictures in the title. I think i will put the names in an array instead.

    but how can i link this to the other array?
    Last edited by Andrew-J2000; Feb 14, 2002 at 09:49.

  4. #4
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've got some code at work that's perfect for what you're looking for. Lokk for it in about an hour or so.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  5. #5
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Arrrr thanx

    Saved me a loada time cheers :P

  6. #6
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK...this code will do for you:

    <script language="JavaScript">
    <!--

    function randomImage() {
    picture = new Array();
    text = new Array();
    picture[0] = 'images/one.jpg';
    picture[1] = 'images/two.jpg';
    picture[2] = 'images/three.jpg';
    picture[3] = 'images/four.jpg';
    text[0] = 'text item #one';
    text[1] = 'text item #two';
    text[2] = 'text item #three;
    text[3] = 'text item #four';
    randomNum = Math.floor(Math.random()*picture.length);
    newImage = picture[randomNum];
    newHex = text[randomNum];
    }

    // -->
    </script>

    Call it like so:

    <script language="javascript">
    randomImage();
    document.write(newtext)
    document.write('<img src="' + newImage + '">');
    </script>
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  7. #7
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hmmm

    Cant seem to get it to work

  8. #8
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could you give a little more detail?
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  9. #9
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile Thanx for any help

    basically i need to link each picture with a list of names, so when someone mouseovers a link they get a list of people in the photo's, whilst the img switch's.

    I want to list each persons name in an array so i can easily, add there name instead of the switch statement.
    So for img 01.jpg will have say creole, Andy in the title. And for each img to be able to change the people.

    Hope thats a bit clearer.

    ps. Sry I didn't post the url i aint got it online yet

    <script>

    var howMany = 5
    var url = new Array (howMany + 1);
    url[0] = '01.jpg';
    url[1] = '02.jpg';
    url[2] = '03.jpg';
    url[3] = '04.jpg';
    url[4] = '05.jpg';
    url[5] = '06.jpg';

    for (num = 0; num <= howMany; num++)
    {
    document.write ("<a href='javascript:void(0)' onmouseover='activate(" + num + ")'>Img " + num + "</a> | ");
    if (num == 10) {document.write("<br>");}
    }

    with (window)
    {
    defaultStatus = "Welcome";
    }

    with (document)
    {
    write ("<html>");

    write ("<head>");
    write ("<link rel='shortcut icon' href='http://www.blah.com/blah.ico'>");

    title = "" + window.clientInformation.appName;

    bgColor = "black";
    fgColor = "White";
    linkColor = "White";
    alinkColor = "White";
    vlinkColor = "White";

    write ("<style>");
    write ("a:hover {");
    write ("color: #000000;");
    write ("background-color: #FFFFFF");
    write ("}");
    write ("</style>");

    write ("</head>");
    write ("<body topmargin='0' leftmargin='0'>");

    write ("<div align='center'>");
    write ("<center>");
    write ("<table border='0' width='100%' height='540'>");
    write ("<tr>");
    write ("<td width='363' valign='middle' align='center'>");

    img = url[0]
    write ("<img name='img' id='img' border='0' src=" + img + " width='500' height='500'>")

    write ("</body>");
    write ("</html>");

    write('<br><A HREF="javascript:favorites()">Bookmark this site!</A>')


    }

    function activate(num)
    {
    with (document)
    {
    images["img"].src = url[num];

    }
    }

    function SelectPeep(Persons)
    {
    switch (Persons)
    {
    case 1 : Persons = "name 1"; break;
    case 2 : Persons = "name 2"; break;
    case 3 : Persons = "name 3"; break;
    case 4 : Persons = "name 4"; break;
    case 5 : Persons = "name 5"; break;
    case 6 : Persons = "name 6"; break;
    case 7 : Persons = "name 7"; break;

    }
    document.title = Persons
    }

    function addfavs()
    {
    var url= window.location
    var title= window.document.title
    window.external.AddFavorite(url,title)

    }

    </script>

    Thanks again and dont get a wireless connection, I keep geting disconnected every 5 sec's

  10. #10
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok...I won't.

    Let's get this moved into the Javascript forum. I think I've taken you about as far as I can.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  11. #11
    SitePoint Enthusiast slp's Avatar
    Join Date
    May 2001
    Location
    Australia
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, I'm not 100% sure what you're trying to do (especially when it comes to putting the people's names in the titles) but I have an idea how you could put the name and photo info into arrays.

    You could try something like this:
    Code:
    
    <html>
    <head>
    <script language="javascript">
    
    function clearit()
    {document.namelist.display.value="";}
    
    persons = new Array('Dopey', 'Sneezy', 'Bashful', 'Grumpy', 'Happy', 'Sleepy', 'Doc');
    
    var howmanyphotos = 5;
    
    photos = new Array(howmanyphotos + 1);
    photos[1] = new Array(0, 1, 0, 1, 1, 0, 1); 
    photos[2] = new Array(1, 1, 0, 0, 1, 1, 0); 
    photos[3] = new Array(1, 1, 1, 0, 1, 1, 1); 
    photos[4] = new Array(1, 0, 0, 0, 1, 1, 0);
    photos[5] = new Array(1, 0, 0, 0, 0, 1, 0); 
    
    */
    each row represents one photo
    1 means persons[j] is in the photo
    0 means persons[j] is not in the photo
    where j is the 'column' number
    eg. only Dopey & Sleepy in photo 5 
    */
    
    var url = new Array (howmanyphotos + 1);
    for (i = 0; i < howmanyphotos + 1; i++)
      { url[i]  = i + ".jpg" ;}
    // image filenames are 0.jpg (blank)
    // and 1.jpg , ... , 5.jpg (photos)
    
    function activate(photonum)
    {
    clearit();
    if (document.images)
    	{
    	document.images["img"].src = url[photonum];
    	}
    for (var persnum = 0; persnum < photos[1].length; persnum++)
    	{
    		if (photos[photonum][persnum] == 1)
    		{
    		document.namelist.display.value += persons[persnum] +"\n";
    		}
    	}
    }
    </script>
    </head>
    
    <body onload="clearit()">
    <center>
    
    <script language="javascript">
    for (var i = 1; i <= howmanyphotos; i++)
    	{
    	document.write ("<a href='javascript:void(0)' onmouseover='activate(" + i + ")'	>Img " + i + "</a> | ");
    	if (i == 10)  {document.write("<br>");}
    	}
    img = url[0];
    document.write ("<br><br><img name='img' id='img' border='0' src=" + img + " width='50' height='50'>");
    </script>
    
    
    <form name="namelist">
    <textarea rows="7" cols="20" name="display"></textarea>
    </form>
    
    </center>
    </body>
    </html>
    
    

    Of course, I don't know how you want to display the photo labels. The only thing I could think of was a textarea, but I'm sure there are other more sophisticated ways ( - one day I have to learn about layers!).

  12. #12
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Is this what you want?

    var Persons = new Array();
    Persons[0] = 'Me, you, and somebody else';
    Persons[1] = 'Me and somebody else';
    Persons[2] = 'Me';
    Persons[3] = 'You and somebody else';

    function activate(num)
    {
    document.images["img"].src = url[num];
    document.title = Persons[parseInt(num,10)];
    }

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  13. #13
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Wink Cheers, its on-line now ;)

    Thanks for the help so far, I have put the website online @ http://www.angelfire.com/extreme3/andrewj/Test.html
    http://www.angelfire.com/extreme3/andrewj/test.js


    I added, a few things that need doing and I hope its clear what I am trying to do now.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •