Rotating images problems

Discussion in 'ASP' started by dcassara, Jan 17, 2016.

Thread Status:
Not open for further replies.
  1. dcassara

    dcassara New Member

    Joined:
    Jan 17, 2016
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Hi - thanks in advance for any help you can give!

    Here is the code I'm trying to get to work - I'm guessing the problem is that there is no submit of the form or the problem is in the javascript - don't know it that well.
    It's not getting the value from the hidden fields on the getElementById.
    I've checked to make sure the database has records and they are being loaded into the hidden fields - no problems there.
    HTML:
    <!DOCTYPE html>
    <!-- #include file = "connectMySQL.asp" -->
    <body   onload="RotateImages(0);">
    <form  method="post" id="ProductList" name="ProductList">
    <%
    	SQL = "SELECT * FROM ads WHERE page='Product'"  
    	ctrA=-1
      	Set rs = SQL_Cn.Execute(sql)
      	arrAds = rs.GetRows
      	ctrA = ubound(arrAds,2)
      	rs.Close
      	Set rs = Nothing
    
         	if ctrA >= 0 then
              for y = 0 to ctrA  
    %>
                 <input type="hidden" id="img<%=y%>" value="<%=arrAds(2,y)%>">
                 <input type="hidden" id="lnk<%=y%>" value="<%=arrAds(8,y)%>">
    <%      next
            end if 
    %>
     <table style="width:100%;border:0px;margin-top:-8px"><Tr>
     <td style="width:50%">
        <img src="Logo.png">
     </td>
     <td style="vertical-align:top;margin: 20px auto;position: relative;width: 50%;">
       <% if ctrA >= 0 then %>
                 <a id="imageurl" ><img id="Rotating1" border="0"  style="position: absolute;left: 45%;margin-left: -50px;width:350px;height:100px"></img></a>
        <% end if %>
    </td></table>
    
    <script language="JavaScript">
    
       function RotateImages(Start)
      {
          var img0=document.getElementById('img0');
          var img1=document.getElementById('img1'); 
          var a = new Array(img1,img0);
          var c = new Array("url1", "url2", "url3", "url4");
          var b = document.getElementById('Rotating1');
          var d = document.getElementById('imageurl');
          if(Start>=a.length)
              Start=0;
          b.src = a[Start];
          d.href = c[Start];
          window.setTimeout("RotateImages(" + (Start+1) + ")",3000);
      }
      
       //RotateImages(0);
      
      </script>
    
    So any ideas on how to accomplish this will help!
    Again, thanks for any help!
     
  2. dcassara

    dcassara New Member

    Joined:
    Jan 17, 2016
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    by the way - I'm only concerned with the images - not the url for now.
     
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    When your HTML outputs whats the value of img0 as ID.
     
  4. dcassara

    dcassara New Member

    Joined:
    Jan 17, 2016
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    [object%20HTMLInputElement] 404 (Not Found)
     
  5. dcassara

    dcassara New Member

    Joined:
    Jan 17, 2016
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    At the time the hidden fields are loaded, the values are
    img0=1-BoxAd.png
    img1=iform.png
    but it's not reading that from the getElementById.
     
  6. dcassara

    dcassara New Member

    Joined:
    Jan 17, 2016
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Spent all day just to figure out I needed:
    var img0=document.getElementById('img0').value;

    I'm a newbie - how do I close this?
     
  7. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    I don't think the img0 id is being printed in the first place. Check for null and see if it there is any output.

    Just alert(document.getElementById('img0')); before you fetch and see what alter shows you.
     
  8. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
Thread Status:
Not open for further replies.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice