brechtjah 16 Junior Poster in Training

To help you out a bit more;
To use cout you need to have iostream included

#include <iostream>

Also, don't forget to use
system("pause");
because otherwise your console window will close immediatly and you won't be able to see your code running : - )

brechtjah 16 Junior Poster in Training

When I try to access http://www.airedale911.org/gen_validatorv31.js it says "The system cannot find the file specified."
Maybe that is where your problem lies, otherwise I'll have to see that code in gen_validatorv31.js

Hope this helps : - )

brechtjah 16 Junior Poster in Training

I'm not sure how you are going to check for that application so I just corrected some of your code and made it redirect, mind you that now the user doesn't have the needed application by standard. If you want to change that, you'll have to call a function, which is probably the myAppInit() one to change that value.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<script type="text/javascript">
		myApp=0;
		function myAppInit(tool) {
			myApp=1;
		}

		function checkMyApp(){
			if(myApp!=1) {
				window.location.href="http://mydomain.com/MediaGate/tabid/199/language/en-US/Default.aspx";
			}
		}
		</script>
	</head>
	
	<body>
		<a href="#" onClick="javascript:checkMyApp();">Click here</a>
	</body>
</html>

Hope this helps : - )

brechtjah 16 Junior Poster in Training

<SCRIPT LANGUAGE="Javascript"> is depreciated, use type instead:
<script type="text/javascript">
capital tags are not needed by the way, just so you know : - )

Your problem probably lies here:

<DIV ID="countrydiv">
<SELECT NAME="Area" onchange="getSelect('Area', this.value,'Region','regiondiv');">
<OPTION>Country1</OPTION>
<OPTION>Country2</OPTION>
</SELECT>
</DIV>

<DIV ID="regiondiv">
<SELECT NAME="Area" onChange="getSelect('Area', this.value,'County','countydiv');">
</SELECT>
</DIV>

When you call getSelect(), you are forgetting to put single quotes around the div's name too.

brechtjah 16 Junior Poster in Training

This shows you how to create a random number in Javascript:
http://www.javascriptkit.com/javatutors/randomnum.shtml

That random number would allow you to go trough your array of quotes. That array can be filled by reading from a file:
http://www.javascripter.net/faq/reading2.htm#top

Although I suggest just filling an array in another .js file and then including it in your html file like this:
<script type="text/javascript" src="quotes.js">

in quotes.js:

var quotes = new Array(100);
quotes[0]="SomeRandomQuote";
quotes[1]="AnotherRandomQuote";
quotes[2]="GuessWhat";
// ... Etcetera
function returnQuote(randomNumber) {
  return quotes[randomNumber];
}

This would mean everytime you want a random quote you just generate the number and call returnQuote(randomNum) with it.

EDIT: example to help you on the way : - )

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<script type="text/javascript">
			var quotes = new Array(100);
			quotes[0]="SomeRandomQuote";
			quotes[1]="AnotherRandomQuote";
			quotes[2]="GuessWhat";
			// ... Etcetera
			function returnQuote(randomNumber) {
				return quotes[randomNumber];
			}
		</script>
	</head>
	
	<body>
		<div id="randomQuote" style="width: 200px; height: 300px; background-color: #bbbbbb;" onClick="javascript:getElementById('randomQuote').innerHTML = returnQuote('1');">
		</div>
	</body>
</html>
brechtjah 16 Junior Poster in Training

1. XMLHttpRequestObject.status returns HTTP status codes; if it returns a 200, which you check for here, that means that everything is OK.
See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for more info. I suggest you read this too: http://www.modelworks.com/ajax.html

2. Have you changed any settings related to redirecting or port usage? I have changed my access port to a number higher than 10000 for ISP reasons, therefore when I try to access localhost it doesn't work I have to access it by:
localhost:[port number] (as in: localhost:54321 for example)
There is nothing wrong with leaving out the directories and just typing the filename, better yet, this makes sure if you change the directory of the file, you do not have to scan each php file in which you use that data.txt and change it to newmap/data.txt

3. Are you still running from your htdocs, then that should work, also, how are you accessing this file then if it is not placed in your localhost as you say. Either way, because the directory of the data.txt is not specified it is exactly normal that everything still works.

Hope this helps,
if you have any questions, please post them.

brechtjah 16 Junior Poster in Training
onclick="if(this.checked == 1) { alert('checked: '+<? echo $newArray['id'];?>); }"

Hopefully this is what you want : - )

brechtjah 16 Junior Poster in Training

I should stop writing my posts so late, anyway
Looking back at my previous post I don't even think you HAVE to give them a unique ID to be able to iterate trough them. ID is there to give each element a unique identifier though, I cannot locate that site you talk of, maybe you can point me to it so I can read up on that. Anyway, if you could give me a piece of code I could try and help with that, see where that goes.

brechtjah 16 Junior Poster in Training

Can you add that full page's code to a reply please...

brechtjah 16 Junior Poster in Training

What you need to do in PHP is give each checkbox an individual ID then,
as in:

echo "<input type='checkbox' id='checkbox".$i."' name='".$checkboxName."'>&nbsp;</input>";

Now you can iterate trough them in javascript by doing this:

var i;
var isItChecked;
for(i=0;i<9;i++) {
   isItChecked = document.myFormName.elements[i].checked;

}

Hope this helps ^^
brecht

brechtjah 16 Junior Poster in Training

You can iterate trough forum controls with Javascript

var i;
for(i=1;i<18;i++) {
      document.formPermissions.elements[i].checked = 1;
}
brechtjah 16 Junior Poster in Training

How about this:

<script type="text/javascript">
function checkit(formName, checkBox) {
var xx = document.formName.elements.checkBox;
xx.checked = 1;
}
</script>

<form name="myform">
  <input type="checkbox" name="mycheck" onMouseOver="checkit('myform','mycheck')" value="1"> Checking</input>
</form>
brechtjah 16 Junior Poster in Training

I'm trying to create a website navigation with moving images. However, I seem to have a bit problems with it as it bugs out sometimes.

This is my code:

<script type="text/javascript"></script>
                        var goDownH = 300;
			var goUpH = 320;
			
			function goDown(id) {
					if(goDownH < 320) {
						goDownH = goDownH + 1;
						
						document.getElementById(id).style.marginTop = goDownH + "px";
						setTimeout("goDown('"+id+"');", 10);
					}
					else {
						goDownH = 300;
					}
			}
			
			
			function goUp(id) {
					if(goUpH > 300) {
						goUpH = goUpH - 1;
						
						document.getElementById(id).style.marginTop = goUpH + "px";
						setTimeout("goUp('"+id+"');", 10);
					}
					else {
						goUpH = 320;
					}
			}
		</script>
<div id="divNav1" style="position: absolute; margin: 300px 0px 0px 400px;">
			<img src="nav.png" alt="nav" onMouseOver="javascript:goDown('divNav1')" onMouseOut="javascript:goUp('divNav1')">
		</div>
		<div id="divNav2" style="position: absolute; margin: 300px 0px 0px 520px;">
			<img src="nav.png" alt="nav" onMouseOver="javascript:goDown('divNav2')" onMouseOut="javascript:goUp('divNav2')">
		</div>

The code above becomes a problem when I'm moving like crazy with the mouse. Sometimes some DIVs get stuck or they start going up and down really fast.
I don't understand what the problem is so I can't start fixing it.

Brecht

brechtjah 16 Junior Poster in Training

Solved it myself

brechtjah 16 Junior Poster in Training

Hi,
I'm creating the layout for a dynamic webshop, all pictures are getting dynamic IDs to have their elements changed. I'm currently having errors with the code below and have no idea why.

the argument id is not null, however
document.getElementById(id) is. I don't understand how that can happen :S

This is my javascript code

<script type="text/javascript">
			function change_bg(id) {
				if(id != null && document.getElementById(id) != null) {
					document.getElementById(id+'bg').src='product_bg_big.png';
					document.getElementById(id+'fg').src='product_fg_big.png';
					document.getElementById(id).src='product_i_big.png';
				}
				else {
					confirm('');
				}
			}
			
			function change_bg_back(id) {
				if(id != null && document.getElementById(id) != null) {
					document.getElementById(id+'bg').src='product_bg.png';
					document.getElementById(id+'fg').src='product_fg.png';
					document.getElementById(id).src='product_i.png';
				}
				else {
					confirm('');
				}
			}
		</script>

This is my php code:

echo "<td>
<img id='product".$numProduct."fg' src='product_fg.png' alt='product_fg'  onmouseover=javascript:change_bg('product".$numProduct."') onmouseout=javascript:change_bg_back('product".$numProduct."')>
					</td>";

EDIT: what's even stranger is that it all works, when I leave out the if, I just have a FireFox Addon which showed me those errors.
Any help would be very well appreciated.
Thanks

brechtjah 16 Junior Poster in Training

Yeah, my bad;
i² = -1
you can't calculate i but you can use it

brechtjah 16 Junior Poster in Training

If you don't mind add your code and I'll try and take a look at it :)

brechtjah 16 Junior Poster in Training

* -1
The square root of -1 is -1 we say. So it would just make your number negative.
Maybe this documentation is helpful for you too :)
http://en.wikipedia.org/wiki/Complex_number

ohnomis commented: help with complex numbers +1
brechtjah 16 Junior Poster in Training

Well,
the square root of 4 is 2 because 2*2 is 4. So the square root of x is a number which complies to this: y*y = x.
This works for every number that is positive, however, if you try to take the square root of -1, that means you want y

y*y = x
-1 * -1 = oops, no, it's not x!
it's 1 instead of -1. That means there is no square root of -1. We just say it is -1 because we want to be able to calculate complex numbers with it.

Maybe my previous explanation was a little short, I hope this helps :) feel free to ask questions

brechtjah 16 Junior Poster in Training

The square root of 1 is 1, this should lead to the square root of -1 being -1, however, this is imaginary. Taking the square root of a negative number doesn't work.

i = -1

Hope this helps

brechtjah 16 Junior Poster in Training

1 = 1
10 = 2
100 = 4
1000 = 8

You can solve this in more than one way, well I can think of multiple ways atleast ^^
Hope this helps

brechtjah 16 Junior Poster in Training

You want to sort the error array and keep the relationship with the rows in weights array ???

Oh, now I get it,
maybe another way to do this is keeping an ID of every array row.
And while you order one array, locate the ID in the other and move that one too.
Or compare the IDs after the ordering is done, and move them according to that.

You'll need to add an extra dimension to your array for that though...
Hope this helps :)

brechtjah 16 Junior Poster in Training

I'm afraid I'm not getting what you're trying to say. Maybe it's too late for this... :-)
Are you trying to put the content of one array into the other or am I getting you wrong? Please elaborate

brechtjah 16 Junior Poster in Training

1. No I thought it would overwrite it (like if you try to open a file, if it doesn't exist, it creates one)... guess it doesn't. Will look up file delete later (I funnily enough have a C++ tutorial now)

You're declaring an ofstream with the append flag (ios::app) which appends to the file, opens it and adds text instead of overwriting the content. Try it out without that flag, see what happens.

ofstream tempfile ("tempfile.txt", ios::app);
brechtjah 16 Junior Poster in Training

If you want to use cout and cin you'll have to include <iostream> and use namespace std.
A sample program is something like this:

#include <iostream>

int main() {
  int x, y, z, min;     // Don't forget you can declare multiple variables of the same type on the same line

  std::cout<<"Enter 3 numbers: ";
  std::cin>> x >> y >> z;         // When entering the three numbers you have to leave spaces between them here

  min = x;
  if (y<x && y<z)
    y=min;

 if (z<x && z<y)
    z=min;

  std::cout<<"min is : " << min << std::endl;            // This prints text with the first insertion operator '<<', and a variable with the second
  // I added an endline for the beauty of it

  system("pause");   // Pauses the application
  return 0;
}

It's really not that hard, a good site would be: http://www.java2s.com/Tutorial/Cpp/0100__Development/0040__cout.htm
By the way, why give void as an argument to main?

Hope this helps, if you have any questions just post them ^^

EDIT: bah, Ancient Dragon beat me to it

brechtjah 16 Junior Poster in Training

Most of the errors you get are typing errors I presume.
For instance, a lot of times you use max or min, where you're giving min or maxloc as argument to the function.
Also some variables are just not declared in a function, remember that each function has it's own variables if they are not declared globally or given as arguments.

EDIT:
a second look at your code tells me that some errors you are having are also forgetting { or not knowing the syntaxis.

Also, in your main function you have this:

int main() {
  int maxloc, minloc, range, bottom = 0, top = 0;
  double votes [50], min=votes[minloc], max=votes[maxloc];
}

The problem with this code is that maxloc and minloc are not initialised, which means they can be any value. You have to give them a startvalue, (I don't know how your program works, just corrected some errors quickly)

Hopefully this can help you further...

brechtjah 16 Junior Poster in Training

Hmm, you have to understand that char editControl_Content[2]; allocates space for two chars.
The array indexes start from zero, meaning that the only indexes you are allowed to access in this case are:

1) editControl_Content[0]
2) editControl_Content[1]

So, to get the window text (or a single char in this case), use the following

char editControl_Content[2];
GetDlgItemText(hwnd, LOWORD(wParam), editControl_Content, 2);

Note that, if GetDlgItemText() succeeds, it will set editControl_Content[1] to '\0'.

The reason why you got gibberish, is that you passed an illegal address (&editControl_Content[2]) to GetDlgItemText() in the first place.

Oh right, thanks for clearing that up for me, I really appreciate it!

brechtjah 16 Junior Poster in Training

See if this works:

int isNum(char c)
{
    if((int)c > 47 && (int)c < 58) { return(true); }
    return(false);
}

I used your solution, thanks, I'm guessing this effectively rules out any other extended characters for example chinese ones...

brechtjah 16 Junior Poster in Training

You are not getting the window text properly, it should be

char editControl_Content[2];
// the following gets one char into editControl_Content[0] and sets
// editControl_Content[1] to '\0'
int charCount = GetWindowText(GetDlgItem(hwnd, LOWORD(wParam)), editControl_Content, 2);
if(charCount > 0)
{
    // got a char ...
}

And further on, when you use isdigit(), be sure to use the valid index (0) i.e.

if(isdigit(editControl_Content[0]))
...

That doesn't seem right because when I try this:

char editControl_Content[2];
GetDlgItemText(hwnd, LOWORD(wParam), &editControl_Content[2], 2);
            
aString<< editControl_Content[2];
MessageBox(hwnd, aString.str().c_str(), "title", MB_OK);

if I change aString<< editControl_Content[2]; to aString<< editControl_Content[0]; like you're saying I get jibberish, so I put jibberish as argument to isdigit().
Unless I'm mistaken, editControl_Content[2] is a valid argument for isdigit().

Thank

brechtjah 16 Junior Poster in Training

First you're using the wrong "OR". For comparisons it's "||", not the bit-operation 'or' "|".

My bad, it's 0.20 here, typed it wrong...

EDIT: is this because è, ç, à are Extended ASCII?

brechtjah 16 Junior Poster in Training

I have absolutely no clue why the following code works except for the following three characters: ç, à and è. It should rule out all non-digit characters from being written into an edit control. Because it let's those three pass trough I am forced to turn this:

if(!isdigit(editControl_Content[2]))

into this:

if(editControl_Content[2] == 'è' | editControl_Content[2] == 'ç' | editControl_Content[2] == 'à' | !isdigit(editControl_Content[2]))

This is the complete code:

char editControl_Content[2];
GetWindowText(GetDlgItem(hwnd, LOWORD(wParam)), &editControl_Content[2], 2);
            
if(editControl_Content[2] == 'è' | editControl_Content[2] == 'ç' | editControl_Content[2] == 'à' | !isdigit(editControl_Content[2])) {
  SetWindowText(GetDlgItem(hwnd, LOWORD(wParam)), NULL);
}
else if(lockOn == false) {
  SetFocus(GetDlgItem(hwnd, LOWORD(wParam)+1));
}

Any help would be very well appreciated.
Thank you.

brechtjah 16 Junior Poster in Training

2. Use stringstream class (type) which allows stream output (with operator<<) to string type variables. It's the other story. Learn stringstream yourself...

I'll go for the stringstream. It seems easier. Thanks.
Every time I get a bit confused I'll start reading this thread before asking any questions ^^

brechtjah 16 Junior Poster in Training

I understand, yet it seems so silly why it would be like that, atleast in my point of view. I hope you're not tired of helping me because I have two more questions:
1. Is it necessary to convert the integers I want to add to a string

string str;
str = string("this") + " is" + " number " + 1;

2. This code does not seem to work with the win32 equivalent of string LPSTR, any idea how I could do this because LPSTR is char*.

Or perhaps it's better to work with strings than LPSTRs, I have no idea. Are there any downsides to using LPSTR above strings? Please enlighten me.

Thanks everyone for all the help I've gotten so far by the way!

brechtjah 16 Junior Poster in Training

Sorry for taking so long, i've had some net / pc problems. This looks like quite a big code, so im not going to go into finding an exact solution. But, I could suggest you use a Picture Control, set the bitmap for it to display, and try to detect a mouse-click on it (by making it notify the parent), well.. thats how I would do it anyway ;) . Hope this helps.

Yeah, I thought about that already, but it seems so backdoorish (if that's a word ^^). I'll keep looking for a while first, maybe try the win32 group on Google and if all fails I guess I'll have to accept it =) I'll keep you informed, if you'd like that

brechtjah 16 Junior Poster in Training

Oh now I get it, so if you would for some reason want your 1 to be a then you would go like this:

char string[2];
string[0] = 1 + '@';
string[1] = '\0';

I'm still having trouble trying to find how to put two char arrays or strings into one though, if I try this:

string str;
str = "this " + "is " + "a " + "string";

It gives me the following error:
Invalid operands of types const char[] and const char[] to binary 'operator +'

I need this because I'm trying to get a date, time and a number into a string, combined as a filename.

brechtjah 16 Junior Poster in Training

I don't know where and what are you googling.
That's a result of my 5-second googling (1st reference in the reply list):
http://irc.essex.ac.uk/www.iota-six.co.uk/c/b1_the_char_data_type.asp
;)

Yes but what about this 0 I have to add after each line, I thought it was only the null character at the end you had to add.
I don't understand that. If you have something that outputs 1 (integer) and you add '0', doesn't that make 10?

brechtjah 16 Junior Poster in Training
char string[2];
string[0] = function() + '0';
string[1] = '\0';

This seems to work, why? I've googled up a bit but can't figure it out.

brechtjah 16 Junior Poster in Training

I'm sorry but I still don't quite get how I can put integers as text into a char and then print those :(

brechtjah 16 Junior Poster in Training

Hi,
I'm having some frustrating issues with char/strings.
I have a function which returns an unsigned short integer, the unsigned short integer is ALWAYS 1 char long. So if I try this code:

number[2] = function();

So, number[2] should give me the number I want, however, it gives me weird characters.
When I try this with a string it's the same result.
I also tried this:

cha[2] = (char)1;
MessageBox(hwnd, &cha[2], "Title", MB_OK);

Result: ÿÿ, or other jibberish.

Little help here please : - )
Thanks

brechtjah 16 Junior Poster in Training

I've added the entire project to this message. Thanks for taking a look into it.

brechtjah 16 Junior Poster in Training

Hello,
I'm experiencing a little problem with what I'm trying to do:
I've created a large number of buttons with Photoshop, these however, already look like buttons, and are rounded. However, when I put them on a BUTTON control the button looks ugly because it has another button on it.
I have already tried to give the button the BS_FLAT flag however, what I'm now getting is a small black border and a small inner white border, AND even worse, if you click the button it looks like it is selected.
Is there any way to get the buttons the way I want?
If anyone requests some print screens I can submit them if you ask

thanks

brechtjah 16 Junior Poster in Training

I want to simply put an image as background of my parent window. Is it possible to put this into the class?

wc.hbrBackground  = image

I've been looking all over Google, maybe I'm using the wrong keywords but I'm not finding anything. Anyway, on top of that image, would it be possible to clear out the title bar of my form together with the close, minimize buttons? The image I will place as a background already looks like a window...
I'm working with Dev C++ and using Win32 API
If anyone could help me out on this you would be very well appreciated, I'm creating a big program to learn wide aspects of win32