Log in

View Full Version : Looking for some code



rack
04-14-2007, 08:20 PM
I dont know where to begin? I need someone to point me somewhere!

I have a simple little project for school.
I have a table 10 rows 6 columns.
I want to put one word in each cell.
And at the bottom a text window that adds one word clicked from each colum to make a sentence. There are 1 million variants. Which is the point of the project.

I dont know where to begin.

Rack

pcbrainbuster
04-14-2007, 08:43 PM
But isn't that like cheating or something? Or does it not matter???

Twey
04-14-2007, 08:53 PM
Policy with homework tends to be that we help, but don't do it for them.

In this case, however, I've no idea what the OP is trying to describe.

pcbrainbuster
04-14-2007, 08:56 PM
I think he wants there to be 10 rows with six columns, he also wants a word in every box, and when that box is clicked he wants a word at the bottom of the screen that the user clicks then that whole row should go disabled...

It should result in a word at the bottom of the screen...

rack
04-14-2007, 10:48 PM
Its not homework, its just part of a school project.

We dont care about anything going blank or anything.
We just need to click on words and have them appear in a text box at the bottom.

thanx again!

mburt
04-14-2007, 11:10 PM
So:

<p onclick="document.getElementById('area').innerHTML=this.getAttribute('text')" text="My foo test">Click these words</p>
...
<div id="area"></div>

boxxertrumps
04-14-2007, 11:35 PM
You'll want to append the data, not assign.
I'm tempted to expand upon this, it is not that hard...

<p onclick="document.getElementById('area').innerHTML+=this.getAttribute('text')" text=" word">word</p>
...
<div id="area"></div>
<p onclick="document.getElementById('area').innerHTML=''">Reset</p>

mburt
04-14-2007, 11:39 PM
Or, the DOM method:

function add(element,data,append) {
var el = document.getElementById(element);
if (!append) {
while (var f=el.firstChild) el.removeChild(f);
}
el.appendChild(document.createTextNode(data));
}

rack
04-15-2007, 01:45 AM
Thanx everyone!

We are the paper, we are computer illiterate. :)
Or so the computer dept keeps telling us.
But they are not smart enough to do this!

We do not really know how to apply the code.

I went to a project page and uploaded an example file.
Here it is
http://yearthatwas.com/wordgame.htm

If some one could code that for us, boy would that be cool.
We are at least smart enough to apply it to the larger project.
The one million sentences generator.
Though Jimbo here wants to make it the one million questions generator.

I think that if you did this for us, you and others could use it for all sorts of funny things.

thetestingsite
04-15-2007, 02:00 AM
Take a look at this page:

http://phphost.smackum.com/dd/rack.html

and tell me if that is what you were talking about. If so, simply copy the source code and use it as you see fit.

Hope this helps.

//EDIT: Tested in FF 2.0.0.1+ and IE6+ on Windows XP (home and pro).

rack
04-15-2007, 04:13 AM
boy oh boy oh boy...
Thats it!
this is so cool, I might even get laid because I got this!

thankyou thankyou...

Twey
04-15-2007, 10:28 AM
<p onclick="document.getElementById('area').innerHTML=this.getAttribute('text')" text="My foo test">Click these words</p>I'm fairly sure <p> doesn't have a text attribute... the best way of doing it would probably be:
<table id="wordTable">
<tr>
<td>Pig</td>
<td>Cat</td>
<!-- ... -->
</tr>
<tr>
<td>Bird</td>
<td>Dog</td>
<!-- ... -->
</tr>
<!-- ... -->
</table>
<p id="wordTableOutput"></p>
<script type="text/javascript">
for(var i = 0, f = document.getElementById("wordTable").getElementsByTagName("td"), e; e = f[i]; ++i)
e.onclick = function() {
document.getElementById("wordTableOutput").appendChild(
document.createTextNode(" " + this.firstChild.nodeValue)
);
};
f = e = null;
</script>
this is so cool, I might even get laid because I got this!Heheh, people don't believe me when I tell them this about the life of a computer geek :p

thetestingsite, that's not vulgar language (well, past a socially acceptable extent, anyway), and what vulgarity does exist is in the meaning, not the words... censoring the word "laid" doesn't help anything :)