Posts by Graphix which have been Voted Down
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
Posting Pro in Training
434 posts since Aug 2009
Reputation Points: 82
Solved Threads: 75
Skill Endorsements: 0
line 21 - You put pans at 1 every time the loop is repeated.
~G
Graphix
Posting Pro in Training
434 posts since Aug 2009
Reputation Points: 82
Solved Threads: 75
Skill Endorsements: 0
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
Graphix
Posting Pro in Training
434 posts since Aug 2009
Reputation Points: 82
Solved Threads: 75
Skill Endorsements: 0
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
Posting Pro in Training
434 posts since Aug 2009
Reputation Points: 82
Solved Threads: 75
Skill Endorsements: 0
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 ]
Graphix
Posting Pro in Training
434 posts since Aug 2009
Reputation Points: 82
Solved Threads: 75
Skill Endorsements: 0
© 2013 DaniWeb® LLC
Page rendered in 0.0614 seconds
using 2.51MB