using a javascript funtion with php

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matthew Robinson

    using a javascript funtion with php

    im crap with javascript, im not so hot with php, but anyway here's what
    ive got

    <script type="text/javascript">
    var lay1=0
    var lay2=0
    function showpicture() {
    lay2=0
    if (lay1%2==0) {
    document.getEle mentById("L1"). style.display=" block" } else {
    document.getEle mentById("L1"). style.display=" none" }
    document.getEle mentById("L2"). style.display=" none" lay1++
    }
    \
    </script>

    .....and inside a loop (looping through every item in a mysql database


    <a href="#" onclick="showpi cture(); return false">Show A
    Picture Of This Product</a>
    <div id="L1" style="display: none">
    <a href="<?php echo ($picturepath); ?>"
    target="LargeIm age">
    <img src="<?php echo ($picturepath); ?>"
    height=200 alt='Image Of Product'> <font
    size=2><br>Clic k The Image To See It Full
    Size In A New Window</font>
    </a>
    </div>

    $picture path is fine, because it worked before i had the javascript and i
    just had <img src="<?php echo ($picturepath); ?>" height=200 alt='Image Of
    Product'>

    but that script only works the first time i click the "Show A Picture Of
    This Product" hyperlink. if i press the same link further down, it doesn't
    do anything, but the first time i click it on the page, it works for that
    item (if that made any sence)

    im trying to put a hyperlink (or a button, but hyperlink is easier) to
    show a pictures for products only when the specific link is clicked. that
    way it makes it possible to use scaled down images (so the man im writing
    it for only has to upload one fullsize picture rather than two because he
    wanted it hassle free)


    does anybody have any idea how i could make it work how i want to?

    thanks in advancee.


  • Fred H

    #2
    Re: using a javascript funtion with php

    [color=blue]
    > $picture path is fine, because it worked before i had the javascript and[/color]

    So this is a js question, not a php question. So please address a js group.

    --
    Fred H

    void FredH::Contact( ) {
    TextToSpeach.sa y("frode at age dee dee dot en oh");
    }

    Comment

    Working...