Graphix 68 ---

Perhaps you should use properly write your programs, instead of scrambling it up, putting everything right next to eachother? Use more enters to seperate each line.

No one will voluntairly read through someone else's code which is poorly written and try to figure out what the hell he is trying to accomplish with it. If you could isolate the problem and post small pieces of it which causes the problem, then perhaps we would.

~G

Graphix 68 ---

line 21 - You put pans at 1 every time the loop is repeated.

~G

aladar04 commented: sorry, not helpful. +0
Graphix 68 ---

Hey everybody,

Lately I have written the game Hangman in many different languages (C, JavaScript, Java and PHP so far). Here is the code snippet for JavaScript! It uses a words file, on the bottom of this post you will see a small example of a few words. The source code for other languages can be found here on DaniWeb and on my new website: .

You can adjust the words file in the initGame() function (line 81). The words need to be separated by a |. Words files can be found can be found here. By default, the images made by Symbol Webdesign will be used. If you want to change the imagesource, adjust the HTML part and also the showHangman() function. They need to be begin with 'hm', the error amount and then the extension (example: hm1.bmp).

~G

words.txt:

computer|radio|calculator|teacher|bureau|police|geometry|president|subject|country|enviroment|classroom|animals|province|month|politics|puzzle|instrument|kitchen|language|vampire|ghost|solution|service|software
Salem commented: spam http://www.daniweb.com/code/snippet267046.html -4
Graphix 68 ---

You should do the following:

- Create a function that needs one argument, which is the id of the input.

- The function retrieves the value using document.getElementById(id) and then adds the part of text you want on the end.

- Then you update the value of the input with the one with the text on the end.

- The function should be called using the event onsubmit="return function()" in the <form> tag


A small start:

function addText(id) {
var text = document.getElementById(id).value;

// Here comes the rest of the code...

return true;
}

~G

Graphix 68 ---

My suggestion:

<?php
function encode_num($number) {
switch($number) {

case 1 :
return "a";
break;

case 2 :
return "b";
break;

case 3 :
return "c";
break;

// ... Alot of code...
// ...Here comes all the other options...
// ...Alot of code...

default:
return "Invalid number";
break;
}
}

function decode_num($string) {
switch($string) {

case "a" :
return 1;
break;

case "b" :
return 2;
break;

case "c" :
return 3;
break;

// ... Alot of code...
// ...Here comes all the other options...
// ...Alot of code...

default:
return "Invalid string";
break;
}
}
echo "The letter 'c' decoded: ".decode_num('c')."<br />";
echo "The number '3' encoded: ".encode_num('3')."<br />";
?>

~G

Graphix 68 ---

I'm having a problem with IE, while it works in FF: the var doesn't save any \n aka enter.

I have the following code:

<script type="text/javascript">
function addu() {
var message = window.prompt("Enter the text that needs to be underlined below");
if (message != "" && message != "null") {
document.editform.text.innerHTML += "\[u\]" + message + "\[/u\]";
}
}
</script>
<img src="beheerimages/ubutton.jpg" onClick="addu()" /><br />
<form name='editform'>
<textarea class="editarea" name="text" cols="100" rows="20"><?php echo $row['bbtext']; ?></textarea>
</form>

Does anyone know a answer to this question? As soon as a user presses the ubutton.jpg image, the enters are deleted.

~G

EDIT: the \[ and \] are to prevent the auto-u of daniweb, in the script it is [ and ]