Results 1 to 3 of 3

Thread: Dynamic Image Selector (dynamic3)

  1. #1
    Join Date
    Jan 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Dynamic Image Selector (dynamic3)

    I've placed the script into a php function and have it working in multiple instances in one page. Everything is okay except for one thing: if I try to change the text "dynamic3" into a string, it doesn't work anymore.

    For instance, if I change the text "dynamic3" to "foo", it works. but if I change it to foo"."$bar it doesn't. Although, every other piece of text I've converted to strings works just fine.

    Any ideas?

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    foo+"."+$bar
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jan 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1
    foo+"."+$bar
    Thanks for your reply. Unfortunately, that didn't work either. It just echoed out the plus signs.

    This makes no sense. Echoing "dynamic3"."$name (instead of foo"."$bar) works properly - it always has. It's just that the script refuses to work like this.
    PHP Code:
    <?php
        
    echo "
        <form name=\"
    $name"."dynamicselector\">
        <table style=\"width:100%;\">
            <tr>
                <td align=\"left\" width=\"180\">Please choose the 
    $name image:</td>
                <td align=\"left\">
                <select name=\"
    $name"."dynamicselector2\" size=\"1\" class=\"select\" onchange=\"generateimage(this.options[this.selectedIndex].value)\">\n
                <option value=\"../../images/template/spacer.gif\" selected>Select a picture</option>\n"
    ;
                    while(
    $pic readdir($dir)) {
                        
    $picpaths[] = $currentdir."/".$pic;
                    }
                    
    sort($picpaths);
                    foreach(
    $picpaths as $picpath) {
                        if(!
    is_dir($picpath)) {
                            echo 
    '<option value="'.basename($picpath).'">'.basename($picpath).'</option>\n';
                        }
                    }
                echo
    " </select>
                </td>
            </tr>
            <tr>
                <td colspan=\"2\" align=\"left\"><ilayer id=\"
    $name"."dynamic1\" width=\"100%\" height=\"115\"><layer id=\"$name"."dynamic2\" width=\"100%\" height=\"115\"><div id=\"dynamic3"."$name\"></div></layer></ilayer></td>
            </tr>
        </table>
        </form>

        <script>
        var ie4=document.all
        var ns6=document.getElementById
        var tempobj=document.
    $name"."dynamicselector.$name"."dynamicselector2
        if (ie4||ns6)
        var contentobj=document.getElementById? document.getElementById(\"dynamic3"
    ."$name\"): document.all.dynamic3"."$name
        function generateimage(which){
        if (ie4||ns6){
        contentobj.innerHTML='Loading image...'
        contentobj.innerHTML='<img src=\"
    $siteURL"."$directory/'+which+'\" border=\"0\">'
        }
        else if (document.layers){
        document.
    $name"."dynamic1.document.$name"."dynamic2.document.write('<img src=\"$siteURL"."$directory/'+which+'\" border=\"0\">')
        document.
    $name"."dynamic1.document.$name"."dynamic2.document.close()
        }
        else
        alert('You need NS 4+ or IE 4+ to view the images!')
        }
        
        function generatedefault(){
        generateimage(tempobj.options[tempobj.options.selectedIndex].value)
        }
        
        if (ie4||ns6||document.layers){
        if (tempobj.options.selectedIndex!=-1){
        if (ns6)
        generatedefault()
        else
        window.onload=generatedefault
        }
        }
        </script>"
    ;
    ?>
    Last edited by tgavin; 01-05-2006 at 12:49 PM.

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
  •