שלח תשובה

זירת השאלות

672
צפיות
1
תשובות

בעיה בפרסומת מתחלפת

,‏ 24 במאי, 2007

מדוע הקוד הבא לא עובד?

<html>
<head>
<script type="text/javascript">
var randomNum=Math.round(Math.random()*3);
function myfunction()
{
    switch (randomNum)
    {
        case 0:
        document.getElementById('imgId').src = "http://mail.google.com/mail/help/images/logo1.gif";
        document.getElementById('aId').href = "http://mail.google.com/mail/";
        break
        case 1:
        document.getElementById('imgId').src = "http://img273.imageshack.us/img273/7276/sig1cz0.png";
        document.getElementById('aId').href = "http://z3.invisionfree.com/LSF/index.php?";
          break
        case 2:
        document.getElementById('imgId').src = "http://www.elsf.net/forum/style_images/elsf_design/t_new.gif"];
        document.getElementById('aId').href = "http://www.elsf.net/forum/index.php?showforum=46";
          break
        case 3:
        document.getElementById('imgId').src = "matan.jpg";
        document.getElementById('aId').href = "matan.htm";
          break
        default:
        document.getElementById('imgId').src = "advertisement.png";
        document.getElementById('aId').href = "contact.php?adv";
    }
}
</script>
</head>
<body onload="myfunction()">
<div><a id="aId" href=""><img id="imgId" src="" /></a></div>
<form><input type="button" onclick="myfunction()" value="ccc" /></form>
</body>
</html>


תודה.

תגיות:

1 תשובות

  1. ranpollak הגיב:

    ללא נושא
    שים לב שבשורה הזו:

    document.getElementById('imgId').src = "http://www.elsf.net/forum/style_images/elsf_design/t_new.gif"%5D;

    יש לך סגירה מיותרת של סוגריים מרובעים. תמחק וזה אמור לעבוד..

שלח תשובה