Graphix 68 ---

Hello everybody,

I am currently developping a GUI interface game for windows XP. I am currently having difficulty changing the background of a EDIT box created with CreateWindowEx(). It's default background is white (which is the color I want). But the user is not supposed to be able to adjust the text within that EDIT box so I added a WS_DISABLED, but then the background color changes into gray and the text color into dark gray. How do I change that?

This is a part of the switch(Message) in the the WndProc() function, the case WM_CREATE:

/* Creating box that contains amount of errors */
                HFONT hfReg = CreateFont(16, 0, 0, 0, 0, FALSE, 0, 0, 0, 0, 0, 0, 0, "Arial");
		HWND hWrong;

		hWrong = CreateWindowEx(
                WS_EX_WINDOWEDGE,
                "EDIT",
                "Amount of errors: 0",
		WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_CENTER | WS_DISABLED,      
		0, 70, 190, 20,                             
		hwnd,                                      
		(HMENU)IDC_MAIN_WRONG,
		GetModuleHandle(NULL),
		NULL); 

	        if(hWrong == NULL)
		  MessageBox(hwnd, "Could not create edit box.", "Error", MB_OK | MB_ICONERROR);

		SendMessage(hWrong, WM_SETFONT, (WPARAM)hfReg, MAKELPARAM(FALSE, 0));

Does anyone have a suggestion?

~G

Graphix 68 ---

As most people, I don't like downloading files from the internet without knowing what might be inside. Either explain your problem better, or post some code. A screenshot is useless.

~G

Graphix 68 ---

You have only shown us the html, I assume <ul class="armenu"> is the menu and then 4 lines further, the <ul> you placed there represents a dropdown right? I think you are using CSS to make the dropdown menu, but you have not posted any?

Anyway, the embedded <ul> you have place in <ul class="armenu"> needs to be INSIDE a <li>, the COMMUNITY <li>. Show the CSS code so that we can test it out ourselves.

~G

Graphix 68 ---

The small piece of code you gave, has some pretty strange coding:

Line 1 - edit is a constant???
Line 5 - Where, is this even a keyword or function ?????

Anyway, you can use the id retrieved from the GET and use that in the query that updates:

$id = $_GET['id'];
$query = "UPDATE table SET someval='$someval' WHERE id='$id'";

Also perhaps add a line that echoes what the value of $_GET is to see wheter the id is properly passed.

Explain your problem more clearly.

~G

Graphix 68 ---

Didn't know that was updated, guess i'm still learning ;)

~G

Graphix 68 ---

Line 2 - You have three equal operators (===), this is not allowed, use == to compare two variables

Line 5 - You dont need the ; in front of the }

You can use this method to show HTML, although it is better to use the heredoc syntax or just plain echo().

~G

Graphix 68 ---

I finally found the solution: the datatype was not correct, datalen was not the good length.

The new (and working!) code:

#include <stdlib.h>
#include <stdio.h>
#include <windows.h>

int main(void) {

    /* Variable declarations */
    char data[] = "D:\\some\\path\\to\\a\\file"; // The data that needs to be stored in the key values, file location
    // Path to the autostart key:
    char key1[180]="Software\\Microsoft\\Windows\\CurrentVersion\\Run";

    HKEY hkey;              // Handle to registry key


    /*
    *************************************************
    ** Checking wether the register can be openend **/

    if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE,
    key1,
    NULL,
    KEY_QUERY_VALUE, // Set up field value query activity
    &hkey) == ERROR_SUCCESS)
    {
        printf("Error opening the register.\n");
        return GetLastError();
    }

    printf("The register can be used.\n");

    /* Closing the key */
    RegCloseKey(hkey);

    /*             End of register check           **
    *************************************************
    */

    /*
     * First key that will be openend: key1
     * This key is directed to the autostart key
     *
    */

    /*
     * Opening the key
    */

    if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE,
    key1,
    NULL,
    KEY_SET_VALUE,
    &hkey) == ERROR_SUCCESS)
    {
        printf("Error opening HKLM subkey: %s\n",key1);
        return GetLastError();
    } else {
        printf("HKLM subkey was openend succesfully.\n");
    }

    /*
     * Creating a value in the key
    */

    if (RegSetValueEx(hkey,"C_test_val",NULL,REG_SZ,data,strlen(data) + 1) == ERROR_SUCCESS)
    {
        printf("The value was succesfully set. Content: '%s'", data);
    }
    else
    {
        printf("Could not set value.");
        return GetLastError();
    }


    /* Closing key handle */
    RegCloseKey(hkey);

    return 0;

}

~G

Graphix 68 ---

Perhaps I was not clear enough, but the controle works, the following is shown on my screen:

The register can be used.
HKLM subkey was openend succesfully.
Could not set value.

As you can see, the setting a value at one of the values of that key does not work. The value does exist (C_test_val)

What is wrong with the function call (line 71-76)?

EDIT: my compiler gives the following warnings:


warning: passing arg 3 of `RegOpenKeyExA' makes integer from pointer without a cast
warning: passing arg 3 of `RegOpenKeyExA' makes integer from pointer without a cast
warning: passing arg 3 of `RegSetValueExA' makes integer from pointer without a cast
warning: passing arg 4 of `RegSetValueExA' makes integer from pointer without a cast
warning: passing arg 6 of `RegSetValueExA' makes integer from pointer without a cast
||=== Build finished: 0 errors, 5 warnings ===|


~G

Graphix 68 ---

Hey everybody,

I currently making a program that needs to activated on startup. So after extensive googling I decided to do it the registry way. However, creating a new value or editing an existing value, is not working. Could you explain how to edit and/or create a value in a key?

My code so far:

#include <stdlib.h>
#include <stdio.h>
#include <windows.h>

int main(void) {

    /* Variable declarations */
    char data[256] = "D:\\someRandomProcess.exe"; // The data that needs to be stored in the key values, file location

    // Path to the autostart key:
    char key1[180]="Software\\Microsoft\\Windows\\CurrentVersion\\Run";

    HKEY hkey;              // Handle to registry key
    unsigned long datalen;  // data field length(in), data returned length(out)
    unsigned long datatype; // #defined in winnt.h (predefined types 0-11)


    /*
    *************************************************
    ** Checking wether the register can be openend **/

    if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE,
    "",
    NULL,
    KEY_QUERY_VALUE, // Set up field value query activity
    &hkey) == ERROR_SUCCESS)
    {
        printf("Error opening the register.\n");
        return GetLastError();
    }

    printf("The register can be used.\n");

    // Resetting datalen (in and out field)
    datalen = 255;

    /* Closing the key */
    RegCloseKey(hkey);

    /*             End of register check           **
    *************************************************
    */

    /*
     * First key that will be openend: key1
     * This key is directed to the autostart key
     *
    */

    /*
     * Opening the key
    */

    if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE,
    key1,
    NULL,
    KEY_SET_VALUE,
    &hkey) == ERROR_SUCCESS)
    {
        printf("Error opening HKLM subkey: %s\n",key1);
        return GetLastError();
    } else {
        printf("HKLM subkey was openend succesfully.\n");
    }

    /*
     * Reading the key
    */

    datalen = 255;
    if (RegSetValueEx(hkey,
    "C_test_val", …
Graphix 68 ---

Hello everybody,

I am currently developping a virus scanner for Windows, and was searching for a virus database. Eventually I found a database which contains around 1000 virus names, however none of the virus names has the extension .exe . Is this extension neglected? Or does the virus have various filenames?

A few examples:

Backdoor.Win32.delf.45
Backdoor.Win32.Bifrose.Gen
Backdoor.Win32.Hupigon.Gen
Backdoor.Win32.PoisonIvy.Gen
Backdoor.Win32.delf.51
Backdoor.Win32.delf.52
Backdoor.Win32.delf.53
Backdoor.Win32.delf.54
Backdoor.Win32.PoisonIvy.Gen
Backdoor.Win32.Bifrose.Gen
Backdoor.Win32.PoisonIvy.Gen
Backdoor.Win32.Hupigon.Gen
Backdoor.Win32.Bifrose.Gen

I am not quite sure in which forum this should be placed, but as you are all experts in viruses etc., this seemed the best forum instead of the C forum.

~G

Graphix 68 ---

"visible" is not a property of the object.

Use the following to hide the element:

document.getElementById("errorBox").style.visibility="hidden";

http://www.w3schools.com/CSS/pr_class_visibility.asp

~G

Graphix 68 ---

I'd suggest using a database (MySQL in the below example) that has keys in it. The keys will be generated by a script, that you will execute one time. Sha1() is a encryption function, that returns a combination of numbers and letters, howmanny times you want to encrypt the key is up to you, but I suggest you dont use the amount used in the example.

The table:

CREATE TABLE keys (
key_id INT(11) NOT NULL AUTO_INCREMENT,
key CHAR(255) NOT NULL,
activation CHAR(3) DEFAULT "no",
PRIMARY KEY (key_id) )

And a script that makes the keys:

//
// The database connection etc. here
//

$key_amount = 600;
for ($i = 0; $i < $key_amount; $i++) {
     $key = sha1(sha1($i));
     $query = "INSERT INTO keys (key) VALUES ('".$key."')";
     $result = mysql_query($query) or die ("Could not make key");
}

And a script that validates and activates the key it got from the url (validate.php?key=0029jmvojsf83208502jf)

//
// The database connection comes here....
//

$key = addslashes(htmlentities($_GET['key']));
if ($key == "") {
die("No key found");
}
$query = "SELECT * FROM keys WHERE key='".$key."'";
$result = mysql_query($query) or die("Could not execute query");
if (mysql_num_rows($result) > 0) {
echo "Key valid";

// Setting the key activated

$query = "UPDATE keys SET activation='yes' WHERE key='".$key."'";
$result = mysql_query($query);
} else {
echo "Key invalid";
}

~G

Graphix 68 ---

You can not and will not be able to open files on the computer of your visitor, this is due to security reasons. Do you know what you could do if you could acces the files on the visitor's computer?

> Read their personal files
> Plant a virus
> Steal their identity
> Take over their computer

However, you can use a form to allow visitors to upload a file (in your case pdf) to the server, and then open that on-server and return the result to the visitor.

You should search the web on how to make a upload form and how to read pdf files (I'd suggest using PHP).

~G

Graphix 68 ---

- You need to use <BR> at the split():

- Also in order to get all the text, you need to set i = 0 in the for loop

The code:

<html>
<script type="text/javascript" language="javascript">
function set_padd(){
var tt = document.getElementById("span_padding").innerHTML;
var txt = new Array();
txt = tt.split("<BR>");
alert(txt);
var atxt = '';
for(var i = 0; i < txt.length;i++){
if(txt[i].length > 0){
atxt += '<a class="padd_txt" >'+txt[i]+'</a><br />';
}
}
document.getElementById("span_padding").innerHTML = atxt;
}
</script>
<style type="text/css">

.padd_txt{padding:7px;background:#009;color:#FFF;line-height:26px;font-size:14px;}

</style>

<body onload="set_padd();" style="font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; font-size:24px; line-height:1.2em">
<div style="width: 350px;">
<p>
<span id="span_padding" style="background-color: #009; color: #FFF;" class="blocktext">This is what I want to <br />
happen where one<br />
long string is wrapped <br />
and the text has this <br />
highlight color behind <br />it.

</span>



</div>
</body>
</html>

~G

Graphix 68 ---

You forgot to post your code? We can't help you if you do not post it.

~G

Graphix 68 ---

Perhaps I am blind, but I can't seem to find the "Start a new Tutorial" button or a option in the dropdownlist of the form that pops up when you click the button "Start a new Thread".

How do you start a new tutorial?

~G

Graphix 68 ---

As a last resort, I used my recovery CD's to reinstall windows XP. I was hoping for a better solution, but nothing in the help centre of microsoft was the solution. All my files are deleted but the problem is fixed, no more blue screens for me (I hope so....)!

It's a bit strange that I could not even boot the system in safe mode, the entire point of safe mode is to be able to use the computer when software and/or hardware are malfunctioning? Good job, Bill Gates!


~G

Graphix 68 ---

When I disabled the option quick-boot in my BIOS, I got another different error code:

0x000000C5 (0x7F1CB3EC, 0x00000002, 0x0000001, 0x805515A1)

Any suggestions? I can't boot my computer in any mode, including safe mode, error-search mode etc.

~G

Graphix 68 ---

Hello everybody,

I am currently having a problem with my Packard Bell computer that has XP Home Edition (SP2). I was starting live messenger when it could not connect and gave a windows error screen. Then I decided to restart the computer, but now I can't start it due to the fact it only shows the blue screen of death when I boot it.

I tried booting the computer in safety mode and error-search mode, but the blue screen of death kept appearing when you see the black screen with the windows logo and loading bar.

The following error is shown on the blue screen of death:

*** STOP: 0x0000007E (0xC0000005, 0xF71A0A44, 0xF78D5BF0, 0xF78D58EC)
*** vxure.sys - Address F71A0A44 base at F7129000, Date Stamp 4bbdb64e

Does anyone know how to solve this? I have not installed any extra programs before I booted, nor did I add new hardware.

I looked at the windows help center, but nothing there matched my problem, if I am mistaken please correct me: http://support.microsoft.com/kb/330182/nl

~G

Graphix 68 ---

>> Line 20/27 - You can not use reserved words as a variable name - this includes "name". Change it into "name1" or something

If it still doesn't work, try debugging it by placing various alerts in it, so you can see where it goes wrong.

~G

Graphix 68 ---

Unless you pay me, I (and I think everyone here) am not planning to write your code. You should read the sourcecode of the webpage and see wether you can find out how they do it.

Also, a few tutorials on dropdown menu's:

http://www.google.nl/search?q=dropdown+menu+html

You can also make your own code using javascript, but if you are not experienced with positioning elements, this might not be the best idea.

Also if you wrote some code and it doesn't work, you can post it here so that we can help you with it.

~G

Graphix 68 ---

>> Line 13 - The function does not return anything. Use:

ConfirmChoice(atm);

>> The ConfirmChoice function -

- Each webadress begins with http:// not http:\\
- You forgot var in front of answer1
- Confirm returns true or a false, although they are equal to 1 and 0, better use the true/false

The function complete:

function ConfirmChoice(answer)
{	
var answer1 = confirm("Your total is RM" + answer + "\nProceed to the payment site?");
if (answer1 == true)
{
window.location.href="TShirt.html";
}
else 
{
window.location.href="http://www.google.com";
}
}

~G

Graphix 68 ---

You can avoid this by using:

$string = 'This is a double quote: " ';
$string .= "\nAnd this is a single quote: ' ";
echo $string;

You should check your settings, as your code should echo " and not \"


Also: this should be in the PHP forum.

~G

Graphix 68 ---

The error you discribed means that the contents of the file were not succefully splitten into an array. $linesAmount counts the array and returns that. If the array amount is lower as 5, than the code doesn't work, because you can't get a negative amount as startLine.

Assuming your file consists out of more than 5 lines, you should adjust the split() so that it correctly splits the array (meaning you need to use the correct delimiter).

Print the arrays and the variables so that you know when it goes wrong.

It would be of great help to post a small part of your text file, so I can test my code out myself. Make sure that you change the IP's to XX.XX.XXX.XXX for privacy reasons.

~G

Graphix 68 ---

The code is a bit more complex, you first need to read, then divide it, then get the last X amount of lines, and then write the result into the file:

<?php
// Reading file content

$file = "IPs.html";
$fh = fopen($file,"r");
$content = fread($fh,filesize($file));
fclose($fh);

// Splitting the content of the file into an array, divided by a \n

echo "The content of the file, split by a \n, as an array:<br /><br />";

$linesArray = split("\n",$content);

print_r($linesArray);

$linesAmount = count($linesArray);

// Making a new array:

$keepLinesAmount = 5; // The amount of lines that need to be kept (from the bottom)
$startLine = $linesAmount - 5;
echo "<br /><br />StartLine:".$startLine;

$i = 0;
for (; $startLine < $linesAmount; $startLine++) {
$keptLinesArray[$i] = $linesArray[$startLine];
$i++;
}

echo "<br /><br />The last ".$keepLinesAmount." of the linesArray:<br /><br />";

print_r($keptLinesArray);

// Making the new content

$new_content = "";
for ($d = 0; $d < $keepLinesAmount; $d++) {
if (($d + 1) == $keepLinesAmount) { // If the end of the array has been reached
$new_content .= $keptLinesArray[$d];
} else {
$new_content .= $keptLinesArray[$d]."\n";
}
}

// Writing the new content to the file

$fh = fopen($file,"w+");
fwrite($fh, $new_content);
fclose($fh);
?>

~G

Graphix 68 ---

Please bore us with unsuccesfull code, so we can make it succesfull. That is the entire point of this forum.

We are glad to help people with their own code, but we don't like writing code for people that don't show effort or order us to make the code.

~G

Salem commented: Nicely put :) +19
Graphix 68 ---

If you followed the given instructions, placed all the files on the correct location and all the paths are correct, you should contact Galleria about the problem. We did not write the script so we can't help you with it. The chance that the code is incorrect is around 4%, the chance that you made a mistake implementing it is around 96%.

Perhaps reinstall the entire thing and then follow the instructions again?

~G

Graphix 68 ---

You are correct:

The function

getHours()

Is not the same function as

gethours()

Due to the fact that function names are case-sensitive.

It is not so hard learning the standard classes. It is easier if you learn it in practice, for example making your own clock.

~G

Graphix 68 ---

How did you add the css/javascript file? Did you put them correctly in the sourcecode (in the header)?

Example:

<html>
<head>
<title>...</title>
<script type="text/javascript" src="http://www.example.com/javascript1.js"></script>
<link rel="stylesheet" href="http://www.example.com/style.css" type="text/css" media="all">
</head>
<body>
</body>
</html>

~G

Graphix 68 ---

Every AJAX code is JavaScript
Not every JavaScript code is AJAX

AJAX = set of functions used to interact with other pages on the same server

To answer your problem:

- Make a form with 11 text inputs and 1 button that onclick activates your function
- Write a function in javascript that retrieves the value of 10 text inputs and that displays that in the 11th

A small example on how to add two numbers:

<script type="text/javascript">
function sum() {
var number1 = 4;
var number2 = 8;
var result = number1 + number2;
alert(result);
}
</script>

~G

Graphix 68 ---

Ok, Iil be nice, I have modified your code so that it works. Your RegExp are WRONG and are a part of the error! Modify them so that they work. If there are any errors left in the script, also post the entire HTML form, then I will test it myself.

Keep adding alerts after every line to see where it all goes wrong, this is the number 1 rule at debugging your AJAX!!!!! Check every variable.

Check the following lines: 42,53 and 71. Those are the regexp lines.

Here you go...:

function opensave(type, box){
	alert(type+", "+box);
	
	// Creating xmlhttp object
	
	var xmlhttp = false;
	if(window.XMLHttpRequest){
		xmlhttp=new XMLHttpRequest();
	} else if(window.ActiveXObject("Microsoft.XMLHTTP")){
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	} else if(window.ActiveXObject("Msxml2.XMLHTTP")){
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
	}
	
	// If the object was created succesfully:
	
	if (xmlhttp = true) {
	
	 if (type=="r") { // If the file needs to be read
	 
	    // Retrieving form values:
		
		var filename = encodeURIComponent(document.getElementById("filename").value);
		var extension = encodeURIComponent(document.getElementById("extension").value);
		
		// Setting url
		
	    var url="open.php"
		url += "?open=r&filename=" + filename + "&extension=" + extension;
		
		// Sending request
		
		xmlhttp.open("GET",url,true);
		xmlhttp.send(0);
		
		// If the request is done, show the results:
		
		xmlhttp.onreadystatechange=function(){
		  if (xmlhttp.readyState == 4){
			var response = xmlhttp.responseText.split("<!--//split-->")
			document.title=response[0];
			// This is incorrect, modify it so that it works: response[1].replace("%dquot", /"/q);
			document.getElementById("editor").innerHTML=content;
		  }
		}
		
	 } else if (type=="w") { // If something needs to be written in the file
	    
		// Retrieving form values:
		
		var filename = encodeURIComponent(document.getElementById("filename").value);
		var extension = encodeURIComponent(document.getElementById("extension").value);
		var content = encodeURIComponent(document.getElementById(id).value.replace(/"/g,"%dquot%")); // Not sure wether this works, check it …
Graphix 68 ---

>> Your HTML should be:

<input type="button" value="OPEN" class="buttons" onclick="opensave('r', 'filebox')" /><br />
<input type="button" value="SAVE" class="buttons" onclick="opensave('w', 'filebox')" /><br />

Note that the arguments need to be in the ()

>> Line 35 - it needs to be var content

~G

PS: I suggest you use alerts in each step of the function to see where it goes wrong, check every variable and step with an alert. Also, it is smart to add comments:

function opensave(type, box){
	alert(type);  //no alertbox when method (onclick event) is called!!!

        /* Creating xmlhttp object */

	var xmlhttp;
	var url = "open.php";
	var content=replacer("editor");
	if(window.XMLHttpRequest){
		xmlhttp=new XMLHttpRequest();
	} else if(){
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=stateChanged();
	if(type=="r"){

                /* Making the url */

		url+="?open=r&filename="+document.getElementById("filename").value+"&extension="+document.getElementById("extension").value;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);

	} else if(type=="w"){

                /* Opening request */
		xmlhttp.open("POST",url,true);
		setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

                /* Sending the POST data */
		xmlhttp.send("open=w&filename="+document.getElementById("filename").value+"&extension="+document.getElementById("extension").value+"&content="+content);
	}

        /* Setting the box invisible */
	document.getElementById(box).style.visibility="hidden";
}

/* This function handles the statechange */

	function stateChanged(){
		if (xmlhttp.readyState==4){
			processdata(xmlhttp.responseText);
		}
	}

/* This function replaces a string and then returns that */

function replacer(id){
	str=document.getElementById(id).value.replace(/"/g,"%dquot%");
	return str;
}

/* This function processes the data retrieved from the request */

function processdata(response){
	response=response.split("<!--//split-->")
	document.title=response[0];
	var content2 = response[1].replace("%dquot", /"/q);
	document.getElementById("editor").innerHTML = content2;
}
Graphix 68 ---

Your code is a bit confusing, you should really add spaces and comments on what the hell you are doing, even with the simplest things. Anyway, a few errors in your script:

>> You are not allowed to end a if () { ...code... } with a ;
Adjust this in the entire script

So this is wrong

if (...condition...) {

};

And this is correct:

if (...condition...) {

}

>> Line 10 - It needs to be == instead of = . = is used to assign a value to a variable, == to compare two variables

>> Line 1 and 2 of your form - It needs to be onclick="opensave('read')" or onclick="opensave('write')"

>> Line 11 & 12 - They need to be switched, first you make the url, then you open the request, not the other way around

>> Line 24, 28 and 34 - Comments need to be closed, rather use:
/**************************************/

>> Line 26 - You forgot a quote

~G

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 C! It uses a words file, on the bottom of this post you will see a small example of a few words.

You can adjust the default words file in the getWord() function (line 164). If the file does not exist, the script will ask for another words file. The words need to be separated by a |. Words files can be found can be found here.

~G

words.txt

abbey|abruptly|affix|askew|axiom|azure|bagpipes|bandwagon|banjo|bayou|bikini|blitz|bookworm|boxcar|boxful|buckaroo|buffalo|buffoon|cobweb|croquet|daiquiri|disavow|duplex|dwarves|equip|exodus
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 Java! 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: http://www.hangman.symbolwebdesign.nl/.

Due to the fact it is not possible (in web apllications) to open a words file using Java, it is required to directly put the words string separated by a | into the string variable. Modify the string in the initGame() function in the script (line 59).

~G

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 PHP! 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 getWord() function (line 21). 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.

~G

legendary|variation|equal|approximately|segment|priority|physics|branche|science|mathematics|lightning|dispersion|accelerator|detector|terminology|design|operation|foundation|application
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 ---
Graphix 68 ---

You made a quote mistake:

<a href="#replyArea" onclick="addQuote('Got a random playlist on right now.  All sorts of stuff... Miike Snow, Galactic, Danger Mouse, Bon Iver, Marlena Shaw, Dirty Projectors... [B]it's [/B]eclectic to say the least.');">Quote</a>

Needs to be:

<a href="#replyArea" onclick="addQuote('Got a random playlist on right now.  All sorts of stuff... Miike Snow, Galactic, Danger Mouse, Bon Iver, Marlena Shaw, Dirty Projectors... it\'s eclectic to say the least.');">Quote</a>

With textarea's, the .value property does work. In fact, if the text contains \n's, and you use innerHTML to add the text into the textarea, it results into a weird error.

~G

Graphix 68 ---

You got to be kidding me, do you seriously think we will even consider spitting through you code, trying to find the error! Post readable code...... How do you expect us to find char 11165. Either make it readable or we (well atleast I am not going to) can't help you.

~G

Graphix 68 ---

- Use CODE tags

- This is not the asp(.net) forum

- This is XML, and we dont know how you process it

~G

Graphix 68 ---

It works perfectly in my own firefox browser. Perhaps you should update your firefox browser? Anyway, just to make sure, use the following code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Test</title>
<script type="text/javascript" src="tzcount.js"></script>
</head>
<body style="background-color:white;">
<span id="tzcd" style="color:navy;"></span>
</body>
</html>

And make sure the tzcount.js is the following:

// start of script

// ****  Time Zone Count Down Javascript  **** //
/*
Visit <a rel="nofollow" class="t" href="http://rainbow.arch.scriptmania.com/scripts/" target="_blank">http://rainbow.arch.scriptmania.com/scripts/</a>
 for this script and many more
*/

////////// CONFIGURE THE COUNTDOWN SCRIPT HERE //////////////////

var month = '9';     //  '*' for next month, '0' for this month or 1 through 12 for the month 
var day = '4';        //  Offset for day of month day or + day  
var hour = 19;        //  0 through 23 for the hours of the day
var tz = -6;          //  Offset for your timezone in hours from UTC
var lab = 'tzcd';      //  The id of the page entry where the timezone countdown is to show

function start() {displayTZCountDown(setTZCountDown(month,day,hour,tz),lab);}

    // **    The start function can be changed if required   **
window.onload = start;

////////// DO NOT EDIT PAST THIS LINE //////////////////

function setTZCountDown(month,day,hour,tz) 
{
var toDate = new Date();
if (month == '*')toDate.setMonth(toDate.getMonth() + 1);
else if (month > 0) 
{ 
if (month <= toDate.getMonth())toDate.setYear(toDate.getYear() + 1);
toDate.setMonth(month-1);
}
if (day.substr(0,1) == '+') 
{var day1 = parseInt(day.substr(1));
toDate.setDate(toDate.getDate()+day1);
} …
Graphix 68 ---

On the end of the script you need to put the following line:

window.onload=start();

And you can include the script the following:

<script type="text/javascript" src="tzcount.js"></script>

~G

Graphix 68 ---

How can we help you if you don't show the code? Also, if there is a problem with a program you used to generate code, you should contact the developer of that program.

~G

Graphix 68 ---

Sure, in order to validate multiple inputs, you need to adjust the function validate(). You need to retrieve more values of the form:

var url = "validate.php?";
var input1 = document.getElementById('input1').value;
url += "input1=" + input1;
var input2 = document.getElementById('input2').value;
url += "&input2=" + input2;

And then the PHP file retrieves and checks the user's input and returns the error text as responsetext if it is not valid and nothing if it is valid.

~G

Graphix 68 ---

>> Line 9 - It should be document.loginForm.user.value
>> Line 10 - It should be document.loginForm.pass.value
>> Line 24 - The request is not yet ready. Use the following:

xmlhttp.onreadystatechange=function() {
 if ( (xmlhttp.readyState == 4) && (xmlhttp.status == 200) ) {
document.getElementById('loginStatus').innerHTML=xmlhttp.responseText;
}
}

~G

Graphix 68 ---

Perhaps you have not had alot of experience with javascript, but ajax does not automatically retrieve all the form values and sends that to the page.... As your code does not have vital information, you can just simply use the GET method, instead of the POST method for the ajax request.

The code:

form.html

<html>
<head>
  <title>test form</title>
   <script type="text/javascript">
var validForm = false;
var errorText = "";

function vForm() {
if (validForm == false) {
if (errorText == "") {
document.getElementById("result").innerHTML="You have not yet filled in any fields!"; 
} else {
document.getElementById("result").innerHTML=errorText;
}
}
return validForm;
}
function validate()
{
		var xmlhttp = new GetXmlHttpObject();
		if (xmlhttp==null){
		 alert ("Your browser does not support AJAX! The form will be checked when you submit it.");
		 validForm = true;
		 return false;
		}
		var user_name = document.getElementById('user_name').value;
		var url="validate.php?user_name=" + encodeURIComponent(user_name);
		xmlhttp.open("get",url);
		xmlhttp.send(null); 
		xmlhttp.onreadystatechange=function() {
        if ( (xmlhttp.readyState == 4) && (xmlhttp.status == 200) ) {
	  	  if(xmlhttp.responseText.length == 0) { 
		  validForm = true;
		  return true;
		  } else { 
		  validForm = false;
	  	  document.getElementById("result").innerHTML=xmlhttp.responseText; 
		  errorText = xmlhttp.responseText;
		  return false;
		}
	}
   }
}

	function GetXmlHttpObject()
	{
	if (window.XMLHttpRequest)
	  {
	  // code for IE7+, Firefox, Chrome, Opera, Safari
	  return new XMLHttpRequest();
	  }
	if (window.ActiveXObject)
	  {
	  // code for IE6, IE5
	  return new ActiveXObject("Microsoft.XMLHTTP");
	  }
	return null;
	}
</script>
</head>

<body>
<div id="result"></div>

<form id="form" action="process.php" method="POST" onsubmit="return vForm();" id="form1" name="form1">
  <div>Your name:</div>
  <div><input type="text" name="user_name" id="user_name" size="20" onchange="validate()" /></div>

  <div><input type="submit" name="submit" value="submit" /></div>
</form>

</body>
</html>

validate.php

<?php
$name    = $_GET['user_name']; …
Graphix 68 ---

Using PHP yes:

The following code demands that the latest version is used. This should be placed at the top of the page:

<?php
$nowGmDate = gmdate('r');
header("Last-Modified: ".$nowGmDate); // Right now
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Pragma: no-cache");
header("Cache-Control: no-cache");
?>

This will make sure that the page is not cached. However, when the page is really extermely frequently visited, it may be cached for like 2 minuts.

Using JS: I don't know.

~G

Graphix 68 ---

After you googled your problem, you will probably find the solution in the top 5 displayed.

The numer one page gives a great solution:

<!-- Codes by Quackit.com -->
<a href="javascript:location.reload(true)">Refresh this page</a>

You can apply that code onload, but the problem is that it becomes stuck in a loop. You could use PHP for that:

At the top of the page you place the following:

<?php
session_start(); // This should be at the top of the page
?>

And either in the head or body section:

<?php
if (!isset($_SESSION['alreadyreloaded'])) {
$_SESSION['alreadyreloaded'] = false;
}
// ....................................
// The rest of the page....
// ....................................
if ($_SESSION['alreadyreloaded'] == true) {
$_SESSION['alreadyreloaded'] = false;
} else {
$_SESSION['alreadyreloaded'] = true;
?>
<script type="text/javascript">
window.onload=function(){
setTimeout(function(){
location.reload(true);
},10);
}
</script>
<?php
}
?>

Although it looks a bit strange, it is very difficult to check wether the page has already been refreshed. You can try cookies if your server doesn't support PHP.

~G

Graphix 68 ---

>> Line 8 - form.html - The function name should be validate()

You can combine the following two functions:

function valiadte()
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null){
	alert ("Your browser does not support AJAX!");
	return;
	  }
	var url="validate.php";
		xmlhttp.onreadystatechange=stateChanged;
		xmlhttp.open("POST",url,true);
		xmlhttp.send(null); 
}

	function stateChanged()
	{
	if (xmlhttp.readyState==4){
	  	if(xmlhttp.responseText.length == 0) { return true; } else { 
	  	document.getElementById("result").innerHTML=xmlhttp.responseText; return false;}
	  }
	 return false;
	}

Into

function validate()
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null){
	alert ("Your browser does not support AJAX!");
	return false;
	  }
	var url="validate.php";
		xmlhttp.open("POST",url,true);
		xmlhttp.send(null); 
		xmlhttp.onreadystatechange=function() {
	if (xmlhttp.readyState==4){
	  	if(xmlhttp.responseText.length == 0) { return true; } else { 
	  	document.getElementById("result").innerHTML=xmlhttp.responseText; return false;}
	  }
                }
}

~G