Graphix 68 ---

You just simply have a table, which only consists out of one row and some columns that represent settings:

CREATE TABLE settings (
accept_all_citizenship CHAR(3) DEFAULT "yes",
ud_not_citizenship LONGTEXT,
... And some other cols....

And just simply update that with the values returned from the form. Note that the names of your radio-inputs are weird, shouldn't they be 'accept_all_citizenship', and then the values 'yes' and 'no'?

I assume you know how to (My)SQL and PHP works with form handling and executing queries, else I refer you to the reference: http://php.net

~G

Graphix 68 ---
if (isset($_GET['id'])) {
$id = $_GET['id'];
} else {
$id = 1;
}

~G

Graphix 68 ---

You are confusing PHP with JavaScript. I think you want to change the content of the textarea, depending on what option is selected. I think you want something like this:

<script type='text/javascript'>
function ChgBox(number) {


   var thecontent = document.getElementById(number).innerHTML;
   document.getElementById('content').value = thecontent;	
	
}
</script>

<select onchange='ChgBox(this.value);'>
  <option value='1' >Your comment on</option>
  <option value='3' >Your question on</option>
  <option value='2'>Your image about</option>
  <option value='0' >Comparison</option>
</select>

... Some other stuff...

<textarea name='content' id='content'></textarea>

~G

Graphix 68 ---

That is not really difficult, and pretty funny someone "copyrighted" this piece of extremely difficult code. Anyways, you can change the contents of a div by adding an ID to it and then calling it with document.getElementById().

Example:

<script type='text/javascript'>
function ChangeMyDiv() {
document.getElementById('MyDiv').innerHTML = 'This is some other text!';
}
</script>
<div id='MyDiv'>This is some text!</div>
<a href='#' onclick='ChangeMyDiv(); return false;'>Change MyDiv</a>

Also, please be aware that the (crappy) code you got there, has a function that writes the fact in the document, instead of changing the innerHTML or innerText of a element. If showFact is called when the document has already been loaded (by an event or something), the page will be blank except for the fact.

~G

Graphix 68 ---

a chatting system cannot be achieved by javascript or PHP alone, you need a combination of both which is AJAX.

What do you think I explained in my posts... Read before you post?

Graphix 68 ---

Also there might be some complications, due to the fact you keep using the same xmlhttp object. The one might not be finished yet, when you call the next one. Perhaps make a different function for the background?

Graphix 68 ---

You use JavaScript functions to open the php-pages that sends the message or retrieves and returns them.

JavaScript function -> Calls PHP-page, which is executed -> PHP-page returns ResponseText

SendMessage(mes) -> Call PHP-page with a GET-data -> Returns nothing, or perhaps something like "Succes" to let you know the message was succesfully stored in the database

GetMessages() -> Calls PHP-page -> PHP-page returns ResponseText that contains the messages -> You set the value of a textarea (or the innerHTML of a div) ResponseText

~G

Graphix 68 ---

It's not a standard function, you need to write it yourself. Here is how it should be:

function SendMessage(mes) {

// Making the xmlhttp object....

var ajax = false;

// Create the object:

// Choose the objecttype, depending on what is supported:
if (window.XMLHttpRequest) {

    // IE 7, Mozilla, Safari, Firefox, Opera, most browsers:
    ajax = new XMLHttpRequest();

} else if (window.ActiveXObject) { // Old IE-browsers

    // Make the type Msxml2.XMLHTTP, if possible:
    try {
        ajax = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e1) { // Else use the other type:
        try {
            ajax = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e2) { }
    }

}

if (ajax) {

   var url = "message_send.php?message=" + encodeURIComponent(mes); // Send the message that was given as paramater for the function

   // Sends request
   ajax.send(null);

   // Function that handles response
   ajax.onreadystatechange=function(){
    // If everything is OK:
    if ( (ajax.readyState == 4) && (ajax.status == 200) ) {
       // Do something if the request was succesfull
       alert("Message was send.");
    }
   }

   ajax.open('get', url);
   ajax.send(null);

}

Now you only need to write the GetMessages() function:

function GetMessages() {
// Make ajax object
// Make a url to messages.php or something
// Create a onreadystatechange function that does something with the ajax.ResponseText which contains the messages
// Open the request
// Send null
}

send_message.php needs to:

- Save the $_GET into a variable
- Save that message in the database

messages.php needs to:

- Retrieve all messages from the database (or a limit of the last …

Graphix 68 ---

You added an excessive " and an extra return false

<a href="mar2010.html" onclick="load('tracklists/mar2010.html','prototype_trk');return false;" "load('bg_feb.html','bg_image');return false;">

needs to be

<a href="mar2010.html" onclick="load('tracklists/mar2010.html','prototype_trk'); load('bg_feb.html','bg_image'); return false;">

~G

PS: There is not a single piece of jQuery in your code.

Graphix 68 ---

There are a few things:

- How are you planning to reload the page, because if you do that every so many seconds, the user gets extremely annoyed due to the fact that he can't type and his text may be gone

- Shouldn't you just simply use AJAX? Two functions are only needed: GetMessages() and SendMessage(txt). GetMessages only refreshes the value of the textarea (without page reload!) in case of a new message. SendMessage is pretty straightforward.

- The correct usage of mysql_connect is: mysql_connect('localhost', 'mysql_user', 'mysql_password');

- Use events rather than form submission

~G

Graphix 68 ---

It's either AJAX or you need to submit a form with the value as a hidden input.

~G

Graphix 68 ---

The php code should be

<?php
echo $_POST['data'];
echo $_POST['res_name'];
?>

And on line 14 it needs to be

http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

~G

Graphix 68 ---

I like the idea, however this is extremely hard to achieve:

>> The user needs to have software installed on his computer, capable of making the type of fingerprint you want (color, resolution etc.)
>> You need to be able to get the image from the user, this is fairly easy
>> You need to match the image with your database of fingerprints images

You might as well join the FBI doing this. Stick to passwords.

~G

Graphix 68 ---

>> Line 34 - there is no declaration of the function showHint
>> LIne 34, 35, 37 - you forgot to end with a ;
>> Line 27 - use <script type="text/javascript"></script>

~G

Graphix 68 ---

It should work, seeing your code. Perhaps change the name of the input to "submitbutton' to avoid complications, also do not use the alt attribute. If that doesn't work, perhaps you should use the following:

<form method="post" name='BidForm'>
... The rest of the table...
<img src='images/console_button_place_bid.gif' alt='Place Bid' onmouseover='this.style.cursor="pointer"' onclick='document.BidForm.submit()' />
</form>

~G

Graphix 68 ---

You can just simply use AJAX to send either GET data or POST data. The following page explains how:

http://www.openjs.com/articles/ajax_xmlhttp_using_post.php

~G

Graphix 68 ---

I personally don't like regex, as it takes alot of processing time and it's syntax is very difficult. You can better use a own written function that just simply loops the string, checking each character whether you want it in or not:

function checkString(var string) {

   var stringlength = string.length;
   var i;
   for (i = 0; i < stringlength; i++) {
      if ((string.substr(i, 1)) == "#") {
         alert("Invalid string!");
      }
   }
}

Anyway, for your regex question: see the following page: http://www.evolt.org/article/Regular_Expressions_in_JavaScript/17/36435/

~G

Graphix 68 ---

Your code seems fine, except for the fact that there does not exist a div with the id 'contentArea'.

There are 2 things why your script might not work:

1. The script is not included. Use:

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

2. The page is not executed on a server. The thing is with AJAX, that it needs a server to function properly, else the readyState and status will never be both 4 and 200

~G

Graphix 68 ---

- What would be better in this situation, to use XML or a TEXT string with the AJAX call back?

Well the easiest way to do this is to let the PHP-script that is called with AJAX to just simply return the entire table (<table> etc. etc. </table>. For example, this is the space in which the table needs to popup:

<div id='TableDiv'>
</div>

and then with the ajax-call/refresh function:

... The call ...
   document.getElementById('TableDiv').innerHTML = xmlhttp.ResponseText;
... The rest of the function ...

- With the "lower list", does each separate line/list element need to be with a form element?

The table can also be something like this, where only 1 form is required. The form can not be submitted, else the page will be reloaded. So you need to add an id to your MySQL-table as well, which is used as an argument in the functions for editing and removing. The edit function and remove function also need to have AJAX-calls to a PHP-script that gets an ID as POST/GET - data. A small example (the 1 in the RemoveTransaction and ShowFormTransaction are the ID's):

<form id='ListForm' method='post' onsubmit='return false;'>
<table
<tr>
<td>A Tranaction name..</td>
<td>Some type</td>
<td>68596</td>
<td>-97900</td>
<td>2009-08-19</td>
<td><input type='button' onclick='RemoveTransaction(1)' value='Remove' /></td>
<td><input type='button' onclick='ShowFormEditTransaction(1)' value='Edit' /></td>
</table>
</form>

- It seems there are so many types of strategies for moving data ...

See previous question

Graphix 68 ---

You are making a list that has:

>> A column with the transaction name
>> A column with the type
>> A column with the positive amount
>> A column with the negative amount
>> A column with the date and time of the transaction
>> A column with a button that onclick shows a form on adding a row
>> A column with a button that onclick shows a form on deleting a row
>> A column with a button that onclick shows a form to edit a row

Do you want the page to be reloaded with every action, or do you want it to automatically reload without the refresh.

If you want the page to reload, you only need to use PHP, MySQL and HTML. Everything is handled by the PHP script, on the reload the PHP script is re-executed and shows HTML depending on what POST/GET data it received. I'd suggest you should read PHP and MySQL for Dummies and XHTML for Dummies.

If you do not want the page to reload, you need to use PHP, MySQL, HTML and JavaScript/AJAX. The forms need to show up by using JavaScript, and when the Delete/Add/Modify button is called, a AJAX call to the PHP-script goes out with the form data and retrieves the new rows after processing the action that is required. This is the more advanced way, but can be the best if you do …

Graphix 68 ---

Perhaps google a bit? You can read a directory easily using PHP:

http://php.net/manual/en/function.readdir.php

~G

Graphix 68 ---

A thread about playing music already exists on DaniWeb: http://www.daniweb.com/forums/thread71948.html

~G

Graphix 68 ---

As far as I could see, there does not exist a counter folder in which a count.db exists. So create a folder named "counter" and create a file in that named "count.db"

~G

Graphix 68 ---

Select the database in the dropdown -> export tab -> Start button -> Depending on the options you selected phpmyadmin will return a sql file or you see it in a textarea.

~G

Graphix 68 ---

It is possible you have not specified a email from which it can be sent, check php.ini at the section of mail options. This problem does not occur on servers, because on most servers the server also has a mail-server.

~G

Graphix 68 ---

I assume you are using javascript-based dropdowns?

Well you need to write a function that is called every time the dropdown-box is changed that loads the content of the dropdown depending on the value:

<select name="myDropDown" id="myDropDown" onchange="LoadDropdown(this.value)">
<option value="1" selected="selected">1</option>
<option value="2">2</option>
</select>

<div id="Dropdownmenu">
Subject A<br />
Subject B
</div>

<script type="text/javascript">
function LoadDropdown(value) {
if (value == "0") {
    document.getElementById("Dropdownmenu").innerHTML = "Subject A<br />Subject B";
} else if (value == "1") {
    document.getElementById("Dropdownmenu").innerHTML = "Subject C<br />Subject D";
}
}
</script>

~G

Graphix 68 ---

Oooh alright, I think I know what you mean. You are loading the <html> and <body> into the html-page, so there are 2 different documents. This is not allowed. Change your SubOne.php to:

This is the subwindow one.

<?php

$MSG=$_POST['MSG'];

if ($MSG) echo "We got a message";
else echo "We did not get any message";

?>

<BR><BR>

<FORM METHOD='POST' ACTION='SubOne.php'>
<INPUT TYPE='SUBMIT' NAME='MSG' VALUE='Form Button'>
</FORM>

(without the <html>, <head> and <body> tags)

~G

Graphix 68 ---

If you only want the form to be submitted from your page, you can use an ID, which is formed out of the current date and some other variables, that is send with the form.

~G

Graphix 68 ---

You can force a download, however you will need to press a "Download"-button for it to be downloaded and openend (depending on your browser settings).

Forcing a download using php (you will have to reload the page every half an hour, i suggest using http://webdesign.about.com/od/metataglibraries/a/aa080300a.htm ):

http://elouai.com/force-download.php

~G

Graphix 68 ---

When a page loads, no form will be automatically submitted. You should check whether the PHP-script also performs a action if no values are submitted (if $_POST is empty) and stop it from doing if that is true:

if ($_POST['search_words'] != "") {
// ... Query the database etc...
}

~G

PS: if you want a form to not be submitted you should write a javascript function that returns true if the query-field is not empty and false if not. You should call it like this:

<form onsubmit="return SearchFieldNotEmpty();" method="post">

and the function should be something like this:

function SearchFieldNotEmpty() {
if (document.getElementById("search_words").value == "") {
return false; 
} else { 
return true; 
}
}

~G

Graphix 68 ---

You first check whether a responsetext is returned before you even sent the request! Also the $MSG will always be empty, as you do not send any post-data with your request.

Graphix 68 ---

Contact the writer of the scripts you are using or the reference manual.

Graphix 68 ---

For the admin panel, you should use a code editor, not a wysiwyg editor, as you can not use bold text in a script, it is just plain text. But anyway, most wysiwyg editors are an extension of a textarea, and can be accessed like every form element. Please note: most wysiwyg editors have different modes, e.g. plaintext, html. The value of the textarea depends on what is the mode.

Example:

This is what you see when you write in the textarea:

Blue is the best color.

And the value of the textarea can be:

Blue is the best color.

or

Blue is the <b>best</b> <u>color</u>.

Depending on the mode, you should check out NicEdit, it is a very good wysiwyg editor: http://nicedit.com/

~G

Graphix 68 ---

A few things I noticed:

>> You added no comments in the code to what you are trying to accomplish
>> Your usage of braces is a bit confusing, there are two ways you can properly use braces:

if (...condition...) {
...Do something...
}

or

if (...condition...)
{
...Do something...
}

or even if the code is only one line

if (...condition...) { ...Do something... }

>> Line 2 and 3 - You forgot to end the lines with a ;

You should use alerts to see how far your code works. And also alert what the responseText is of the ajax call.

~G

Graphix 68 ---

This will work:

<?php
$user_ip = $_SERVER['REMOTE_ADDR'];
include("sec/db.php");
$query = "SELECT * FROM blog_name WHERE ip='".$user_ip."'";
$result = mysql_query($query) or die("Could not execute query");
if ($row = mysql_fetch_array($result)) {
//.... Do something....
}

?>

~G

Graphix 68 ---

I found the solution as I was searching using Google. The C::B GCC compiler does not support this, so you need to install Open Watcom, as set this as your compiler for your project. You can download it at http://www.openwatcom.org/index.php/Download (click one of the mirror links and then go to the Watcom directory and download the .exe file that corresponds with your OS) and installation guide is at http://www.openwatcom.org/index.php/Configuring_Code::Blocks

~G

Graphix 68 ---

Hey everybody,

I am currently having difficulty using GetOpenFileName() and GetSaveFileName(). The keeps returning the error " undefined reference to `_GetOpenFileNameA@4' ". I can't seem to find a fault in my code, so is it the compiler or is it the code? I am using CodeBlocks.

void DoFileOpen(HWND hwnd)
{
	OPENFILENAME ofn;
	char szFileName[MAX_PATH] = ""; // Buffer in which the filename will be placed

	ZeroMemory(&ofn, sizeof(ofn));

	ofn.lStructSize = sizeof(OPENFILENAME);
	ofn.hwndOwner = hwnd;
	ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
	ofn.lpstrFile = szFileName;
	ofn.nMaxFile = MAX_PATH;
	ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
	ofn.lpstrDefExt = "txt";

	if(GetOpenFileName(&ofn))
	{
		HWND hEdit = GetDlgItem(hwnd, IDC_MAIN_EDIT);
		LoadTextFileToEdit(hEdit, szFileName);
	}
}

~G

Graphix 68 ---

Well I have been looking around on how to make a code editor, and perhaps you can make a desktop code editor? A documentation exists on RichEdit at msdn, you should check it out. But I won't be able to help you with it as I am a novice at WinAPI programming, so if you stumble on a problem, you will have to visit the C++/C forum.

The link: http://msdn.microsoft.com/en-us/library/bb787605%28v=VS.85%29.aspx

~G

Graphix 68 ---

Making a code editor is a very difficult task. The problem is that regular textarea's do not allow html to be executed within their text/value, however this can be bypassed but I could not find out how. A graduee at MIT (if I am not mistaken) has made a richt text editor as his final project which works perfectly. Perhaps you should check that out for ideas?

Make sure you download the uncompressed with comments version at the download section: http://nicedit.com/

~G

Graphix 68 ---

Your code works. Only you need to use "checked" as a value for the attribute "checked", as this is the only valid value.

<script type="text/javascript">
function checkAll(checkname, exby) {
for (i = 0; i < checkname.length; i++)
  checkname[i].checked = exby.checked ? "checked" : "";
}
</script>

<form name="form2" method="post" action="?action=evaluate"> 
  <input type="checkbox" name="all" onClick="checkAll(document.form2.checkGroup,this)">Check/Uncheck All<br>
  <input type="checkbox" name="checkGroup" value ="first">First<br>
  <input type="checkbox" name="checkGroup" value ="second">Second<br>
  <input type="checkbox" name="checkGroup" value ="third">Third<br>
  <input type="checkbox" name="checkGroup" value ="fourth">Fourth<br>
<input type="submit" name="Submit" value="Submit" style="height:23px;font-weight:bold;padding-top:0px;">
</form>

But your code works also without this small modification. If not, update your browser, it works in FF and IE.

~G

Graphix 68 ---

You can adjust the OpenLightBox() and CloseLightBox() functions, so that they open and close the in steps. Then the LightBox div ofcourse needs to have a absolute width and height. You can use SetTimeOut() to increase/decrease the width and height in steps untill the max height/width is reached.

Ofcourse you need to write 2 functions: Increase(dimension) and Decrease(dimension). The parameter dimesion can either be "height" or "width", and the max height/width need to be set as global (declared outside the functions). The amount of pixels added each time and what the interval is can be changed.

This is what my approach would be, but there are ofcourse various ways on how to do this.

~G

PS: This sounds like a pretty advanced script, so if you need any help, just ask.

Graphix 68 ---

I guess this is a homework assigment? Well I will tell you how you can do it, but I will not write the code for you.

1. Create the document with the table (it needs to have a id attribute)
2. Write a function in JavaScript that calculates the powers of 2 and dynamically add the rows to the table.

You can learn about adding rows to a table here: http://www.w3schools.com/js/tryit.asp?filename=try_dom_table_insertrow

~G

Graphix 68 ---

Howmanny times do I need to post this on DaniWeb:

AJAX is a set of functions of the language JavaScript

jQuery is a set of functions written in JavaScript, it might be considerate as a library for JavaScript but is not build-in and needs to be included using the script tag. More information: http://jquery.com/

JavaScript is a browser language.

~G

Graphix 68 ---

I did not pay attention to syntax errors, but anyway, here are a few:

>> Line 11 - This might be incorrect, not sure. Perhaps use $curGr = "gamerow".$i;

>> The $i , what is this supposed to do? It is not incremented but only added to a name?

>> line 19 - What do you want as name? Beginning with "game" then add $curGR behind that and behind that $c?????

~G

Graphix 68 ---

First created a php file named for example "process.php"
Set this file as your action within the <form> tag

The options you made do not have values:

<select name="cmcenquiryform">
<option value="Joining Courses">Joining Courses</option>
<option value="Franchisee">Franchisee</option>
<option value="Corporate Training">Corporate Training</option>
<option value="Others">Others</option>
</select>

Retrieving the form values using php is very easy, and is the same for every type of input, so if someone selects "Joining Courses" the value of cmcenquiryform is "Joining Courses". A small example for process.php:

<?php
if (isset($_POST['name'])) {

   // If the value of name is not null:

   $name = $_POST['name'];
   echo "You entered as name: ".$name;

} else {

   // If the value is null:

   echo "You did not enter a name!";

}
?>

~G

Graphix 68 ---

>> Line 28 and 29 - When this page is shown, are you sure they even got values? First check the HTML source code and if that doesn't show that there is nothing, perhaps write a function that alerts the values when the form is submitted using javascript.

~G

Graphix 68 ---

As far as I can see your are pretty close to finishing this. You should check the following things:

A) Is the table correctly printed
B) Are the options for difficulty and level select printed properly
C) Does the function validate_fields() work properly

If the above are all good, you should now focus on a function that uses an AJAX call to retrieve the table from the last script and then print it within a div: GetSudokuPuzzle() or something like that. It should be called instead of the form submit, so in the form tag you put: onsubmit="GetSudokuPuzzle(); return false;"

A small start:

function GetSudokuPuzzle() {
 var valid = validate_fields();
 if (valid == true) {
  //....
  //.... Here comes the AJAX call. You need to save the responseText in a variable, lets say "sudokuTable"
  //....

  // Now you put the sudokuTable within the div
  document.getElementById("sudoku").innerHTML = sudokuTable;
 }
}

You should look for tutorials on the internet on using AJAX: http://www.w3schools.com/ajax/default.asp

~G

Graphix 68 ---

"Light box" is just a fancy name for a popup div and a backgound which opacity (or transparancy) is lowered. I made a small example for you to try out and see how it works:

<!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>
<link rel="stylesheet" href="style1.css" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
#FullScreen {
position:absolute;
top:0px;
left:0px;
width:100%;
height:100%;
z-index:0;
opacity:0.7;
filter:alpha(opacity=70);
background-color:black;
border:0px solid red;
display:none;
}
#LightBox {
display:none;
position:absolute;
top:25%;
left:25%;
width:50%;
height:50%;
border:3px solid #A4A4A4;
background-color:#E4E4E4;
padding:10px;
z-index:1;
}
#LightBoxMenu {
text-align:right;
}
</style>
<script type="text/javascript">
/*
 * Script created by Graphix
 * You can modify this script to your own likings, but please do not remove this warranty.
 * Contact: either PM me at DaniWeb or visit http://www.symbolwebdesign.nl
*/
function OpenLightBox() {
		document.getElementById("LightBox").style.display = "inline";
		document.getElementById("FullScreen").style.display = "inline";
}
function CloseLightBox() {
		document.getElementById("LightBox").style.display = "none";
		document.getElementById("FullScreen").style.display = "none";
}
</script>
<title>Lightbox Example</title>
</head>
<body>
<div id="LightBox">
 <div id="LightBoxMenu">
  <a href="#" onclick='CloseLightBox(); return false;'>[X] Close</a>
 </div>
 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel ligula arcu, ut dapibus tellus. Suspendisse malesuada gravida ante facilisis euismod. Mauris dignissim pulvinar arcu eu aliquet. Duis nec nibh nisi, nec sagittis magna. Duis ipsum nibh, aliquam ut tristique at, dictum vitae ipsum. Proin pretium ultrices libero eu mattis. Etiam felis augue, dapibus in gravida ut, gravida sit amet diam. Quisque ac orci id eros varius bibendum. Suspendisse a pretium tortor. Nunc tincidunt pulvinar …
Graphix 68 ---

The window class hbrBackGround feature only effects the background of the main window, how do I implement that in my code? Do I used the hInstance of the main window? And how do I link a window class with the window, as there is no WNDCLASSEX parameter within CreateWindowEx(). Could you give me a example?

~G

Graphix 68 ---

There are 2 options:

>> You can either search for a script using Google
>> Or make your own lightbox script, it justs needs to do the following things:
--------> Center the div in which the form stands (you can ofcourse make the div look good)
--------> Change the transparancy of the page behind the div (See the w3schools reference)

~G