Jump to content

Corbeau

Members
  • Posts

    11
  • Joined

  • Last visited

Corbeau's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Like I said, this is a drastically simplified version of what I'm trying to do. To expand on it a bit, I'm trying to make this click-on-a-cell trigger a lot more stuff and was hoping this example would show me roughly how to do it. Basically, yeah, it's a game where the table is a part of a (much) larger map; when click happens, coordinates that were clicked on are used to move the map (ship is constantly in the centre), recalculate new coordinates, put into "visual range" (into the table on the screen) everything that needs to be put there from the database and offer additional options depending on what is on the tile/cell that the ship is on now. Anyway, a lot of work in all directions and, this being a side-side-side-side-project of mine and interface programming the part that I'm least interested in (I was also considering doing just the ASCII version in C, and then decided that would REALLY be far too much retro), I was looking for a shortcut. But I guess no such thing as a free lunch As for the confusion, all the things you see as weird are probably the result of my limited understanding of JavaScript. I know programming, but I don't know the specifics of the language, I'm afraid. Thanks again for trying to help and sorry for the confusion.
  2. Sorry, didn't mean to sound daft. I will definitely look into it. But considering the time I have at hand, it will take a lot more time than I had planned. That's what I meant by "mess": other things I'll have to reconsider. Thanks again.
  3. Gh, exactly like i said.... Bigger mess than I could possibly imagine. Thanks.
  4. Hello. I have a feeling this will end up in a much bigger mess than I can possibly imagine, but we have nothing to lose but our ignorance, so what the . I will explain what I need on a drastically simplified example. Suppose I have a basic table 2x2 that I draw using JavaScript. Furthermore, I use a function because the table will be a bit dynamic, with input parameters. One of the cells contains "X", others are empty. xmax and ymax are the number of rows and columns x0 and y0 are "coordinates" of the cell that contains an X. So, the code for this is: <script> function tablica(xmax, ymax, x0, y0) { document.write("<table border='1px'>"); for (var i=1; i<=xmax; i++) { document.write("<tr>"); for (var j=1; j<=ymax; j++) if ((j==x0) && (i==y0)) document.write("<td onclick='myFunction(i,j)'>X</td>") else document.write("<td onclick='myFunction(i,j)'> </td>"); document.write("</tr>"); } document.write("</table>"); } </script> I want the following to happen: when I click on a cell, I want the WHOLE table to reload itself, but with the "X" in the cell that I clicked on. So, can what I want be done at all with innerHTML, if yes, what is the trick, and if no, what would you guys recommend? I took a look at the innerHTML thing. It says: <p id="demo" onclick="myFunction()">Click me to change my HTML content (innerHTML).</p> <script> function myFunction() { document.getElementById("demo").innerHTML = "Paragraph changed!"; } </script> The problem is, with this setup, I can't get the initial table to load itself at all so that I have something to click on. But if I do put a call to function tablica() with some initial values, then it overrides everything and reloads with those initial values, regardless of what the new input is. Thank you. (I probably also switched i-j and/or x-y, but I'll worry about it when I get the thing working)
  5. Thanks. It helped. And the additional advice will come in handy
  6. I have a strong desire to smash the desk with my forehead. So, I have this: .widget { color: #000000; border-top: 1px dotted #b3b3b3; font-size: 18px; font-size: 1.8rem; line-height: 1.6666666666em; margin: 0 0 1.6666666666em; overflow: hidden; padding: 1.6666666666em 0 0 0; font-style: italic; text-shadow: 1px 1px 4px;} The problem? Changing the colour doesn't work! I change the number to #ff0000 and it remains black. The rest of the block is good, I played with the font-style, shadow and size and all those work. To add insult to injury, exactly below it I have: .widget-title { color: #000000; font-size: 15px; font-size: 1.5rem; line-height: 1.3333333333em; margin: 0 0 1.3333333333em 0; text-transform: uppercase;} When I change colour here, it works. I checked spelling, changed the loaction of the text, copy/pasted from below, nothing. Any ideas? (The page is daliborperkovic.com, WordPress template is "Sundance", in case anyone thinks that may help, but please ignore the content, it's not finished yet)
  7. Nope. Still "not a function". And I did check for reserved words, it seems "rad" is legit. Is there any difference if the function is placed in the <head> and the rest of the code in <body>? I tried both separately and all within <body>, neither worked.
  8. Hello. I have a problem that's making me feel like an idiot. I have this function. The exact code is maybe not that important because, if I copy/paste the exact code into the program, it is working (but still appending it just in case). However, when I put it in front of the program, I get "TypeError: rad is not a function". There are other functions so I tried putting him in the same SCRIPT tags, tried to separate them, neither is working. <script>function rad(x,y){ var temp=0; if ((y==0) || ((Math.abs(x)/(Math.abs(y)+0.01))>=2)) temp=Math.abs(x); else temp=Math.abs(y)+div(Math.abs(x),2)+Math.abs(x)%2; if ((Math.abs(x/(y+.01))<2) && (y<0)) temp=temp-Math.abs(x)%2; return temp;}</script> Also, "div" is a defined function and that one is working.
  9. Actually, on a closer look, if I do it like this, I don't even need the JavaScript? At least not for this?
  10. /me slaps himself around a bit with a large trout Thank you. /me bangs his head against the wall a few times Yeah, feeling better. Much, much better.
  11. Hello. I have a table with a cell that says: --- <td id="hex" rowspan=2 height='66' background='hex.gif' onmouseover="hex-active()" onmouseout="hex-normal()"></td>--- Also, predifined functions within main document <head> tags: ---- <head><script>function hex-active(){document.getElementById("hex").innerHTML="<img src=hex-active.gif>";}function hex-normal(){document.getElementById("hex").innerHTML="";}</script></head> ---- According to everything I know, it should be working. But it isn't. Completely dead. Anyone got any idea what could be wrong? Thanks.
×
×
  • Create New...