Jump to content

Random

Members
  • Posts

    12
  • Joined

  • Last visited

Random's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. What I am trying to do is to enter a number of row and columns, than have it generate a table with those numbers and a picture each cell. The picture being different in each one in sequence. Like cell 1 has "HorseA1.jpg" and than cell 2 has "HorseA2.jpg", etc. than after #12 start back from the begining. Here's the code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><title> Assignment 9</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css"> #div1 { font-family: Eras Bold ITC; color: yellow; font-size : 5em; z-index: 1; }#div2 { font-family: Eras Bold ITC; color: yellow; font-size : 1em; z-index: 1; }#div3 { font-family: Eras Bold ITC; color: yellow; font-size : 1em; z-index: 1; }</style><script language = "javascript" type="text/javascript">function validateit(){ if (isNaN(txtRow.value)) { alert ("Please enter an integer for the number of rows."); txtRow.focus(); return false; } else { if (isNaN(txtCol.value)) { alert ("Please enter an integer for the number of columns."); txtCol.focus(); return false; } else { return true; } }} var ImageCnt; function showImage(){var img; if (ImageCnt < 12) {ImageCnt++}; else {ImageCnt=1;}for (var i = 1; i<=ImageCnt; i=i+1) img = "<img src=\"images\\"+HorseA.value+ImageCnt+".jpg\" height=100>";alert (img); document.getElementById("image").src = img; }function CreateIt(){var rCount; var cCount; var txtStr; if (validateit()) { rCount = parseInt(txtRow.value); cCount = parseInt(txtCol.value); txtStr = "<html>\n<head>\n<title>Assignment 9</title>\n</head>\n<body>"; txtStr = txtStr +"<table border='3'>\n"; for (var i = 1; i<=rCount; i=i+1) { txtStr = txtStr + "<tr>\n"; for (var j = 1; j<=cCount; j=j+1) { txtStr = txtStr + "<td width="120" bgcolor="yellow">\n <div id="image" style="width: 120px;"></div> \n </td>\n"; } txtStr = txtStr + "</tr>\n" ; } txtStr = txtStr+"</table>\n"; txtStr = txtStr +"</body>\n</html>" document.writeln (txtStr); return true; } else { return false } } </script> </head><body bgcolor="blue"><div id="div1" align="center">Generating images in a table dyamically</div><table> <tr> <td width="281"><div id="div3" align="right">The number of columns</div></td> <td width="277"> <p> <input type="text" id="txtCol" value="" /> </p></td> </tr> <tr> <td><div id="div2" align="right">The number of rows </div></td> <td><input type="text" id="txtRow"value="" /></td> </tr> <tr> <td> </td> <td><input type="button" id="btnCreate" onclick="CreateIt()" value="Create the table" /></td> </tr></table></body></html>Any help on this would be great
  2. I'm looking for a way to animate different objects, so when you press a button ALL 4 obejects will move in different directions and when you press stop they all return to their starting positions. My main problem is finding a way to adapt what I have to more than one objects. I tried to copy and paste the code again and just add a number to the function/variable/etc. and it didn't, it may be because I would not have a way to start them all at once. So if anyone has a suggestion or maybe a site that has a good tutorial for this I'd really appreciate it. Thanks.Here's what I have so far animating just one of the objects:<html><head><style type="text/css">#div0 { position: absolute; font-family: Rockwell; font-size : 5em; color: #6bfdb3; z-index: 1;}#div1 { position: absolute; font-family: Rockwell; font-size : 5em; color: #6bfdb3; z-index: 2;}#div2 { position: absolute; font-family: Rockwell; font-size : 5em; color: #6bfdb3; z-index: 3;}#div3 { position: absolute; font-family: Rockwell; font-size : 5em; color: #6bfdb3; z-index: 4;}</style><script language="javascript" type="text/javascript">var Hchange=50;var Hstart = 312;var Hstop = 600;var Vstart = 102;var Vstop =100;var Vchange = 50;var animationDelay = 75;var timerID="";function getObject(){ return document.getElementById('div3'); } function shiftIT (x,y,z){ var xStr; var yStr; var zStr; xStr=x.toString(); yStr=y.toString(); zStr=z.toString(); getObject().style.left = xStr +"px"; getObject().style.top = yStr +"px"; getObject().style.zindex = zStr; Hstart = Hstart+Hchange; Vstart = Vstart+Vchange; if (Hstart >=Hstop) {Hstart = 0; } if (Vstart >=Vstop) {Vstart = 0; } }function delayIT (stopTM){ var j; var count = 0; count = 0; for (j=1; j<=stopTM; j=j+1) { count = count+1; }}function stopSide(){ clearInterval(timerID); timerID="";} function moveSide() { if (timerID == "") {timerID = setInterval ("shiftIT(Hstart,Vstart,2)",animationDelay);} }</script></head><body><br /><input id="button" name="button" type="button" onclick="moveSide()" value="Move" style="top:250px;left:50px;z-index:0" /><input id="reset" type="button" value="Reset" /> <div id="div3" style="left: 312px; top: 102px">e</div> </body></html>If anybody has any
  3. Yes I did and thank you so much, I was really stuck and this help me finish, I really appreciate it.
  4. Thanks a lot that really helped, but I want to stay away from prompts and alerts. What I need is to have the user enter th number in a text box on the page than display it, I'm just having problems getting that to work
  5. I'm fairly new to javascript and I have been having trouble learning it. I need to finish a project where I have to be able to type in a number and depending what that number is a message will appear on the screen. Like if I type a number between 1 and 10 message A will appear, 11 to 20: Message B. I have the if else statement set up, I'm just having trouble displying it. If anyone knows off hand how to do it or has an example or a direct link on how to do this I'd really appreciate it. I've searched all over the web and cant seem to find it. Thanks.
×
×
  • Create New...