~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> returnValue= true; This sets the value of the global variable returnValue to true and has got nothing to do with your issue.

> e.returnValue = true; This sets the return value of the event to ' true ' and is a MS only property. So your onclick returns false if the validation fails and thereby prevents form submission.

> e.preventDefault() This cancels / prevents the default action caused by the event. In our case, the click action submits the form which is prevented by calling p reventDefault(). It is important to notice that both e.returnValue = false; and e.preventDefault() in our case achieve the same purpose(of cancelling the forum submission) for different browser types.

OmniX commented: Very helpful information =) +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

switch-case statements can check only integer or character values.

To be more precise, switch statements can handle all Integral types except long. Character values and Integral values are not separate entities as explained below.

A primitive type is predefined by the Java programming language and named by
its reserved keyword (§3.9):

PrimitiveType:
    NumericType
    boolean

NumericType:
    IntegralType
    FloatingPointType

IntegralType: one of
    byte short int long char

FloatingPointType: one of
  float double
Jishnu commented: Right. I was wrong in considering char as a different type. +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

This is because Javascript searches for 'flow()' in the global scope but it so happens that your declaration of flow being present in the function imageFlow is not visible / is not a property of the global object. This can also be attributed to the fact that setTimeout and setInterval always search the global scope.

You can avoid this in many ways, two of which are: Either set this function flow as the property of your function imageFlow or use closures / anonymous functions.

/* Setting the property of imageFlow function */

function imageFlow() {
	var R = 0, x1 = .1, y1 = .05, x2 = .25, y2 = .24, x3 = 1.6, y3 = .24, x4 = 300, y4 = 200, x5 = 300, y5 = 200;
	var DI = document.images, DIL = DI.length;
	var flow = function() {
	    for(var i = 0; i < DIL; i++) {
	        DIS = DI[i].style;
	        DIS.position = 'absolute';
	        DIS.left = Math.sin(R * x1+ i * x2 + x3) * x4 + x5;
	        DIS.top = Math.cos(R * y1 + i * y2 + y3) * y4 + y5;
	    }
	    R++; 
	}
	imageFlow['flow'] = flow;
	setTimeout("imageFlow.flow()", 100);
}
window.onload = imageFlow;
function imageFlow() {
 var R = 0, x1 = .1, y1 = .05, x2 = .25, y2 = .24, x3 = 1.6, y3 = .24, x4 = 300, y4 = 200, x5 = 300, y5 = 200;
 var DI = document.images, DIL = DI.length;
 var flow = function() {
     for(var …
jmasta commented: Excellent explanation and example code +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

A sample chapter on Data Structures in Java from the book Java concepts for Java 5 and 6. A good and thorough read.

ahihihi... commented: :) +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Just to expose your ignorance of India, you may read this news report:
Just to expose your ignorance, that isn't the place where I live. Next time check your facts before trying to act cool.

>> You live in India and drink the water, isn't that dangerous?
> Next time think before you insult someone.
Next time don't try to be sarcastic / pick a fight if you can't handle one.

Sulley's Boo commented: Jug jug jiyo mere shair *roar* .. hehehe .. (this is for the last rep comment u gave me) > tu bhari tu mota tu aloo ki bori tu tu tu tu tu bas tu kameene me tera khoon pee jaungeeee *slaps* +3
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> How is it different from the water you drink ?
Of course it isn't different. There is no point in bothering yourself with kids who have no idea of what they are talking about...

sneekula commented: Stifle yourself, I am not an ignorant kid! +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Don't take it too seriously.
Just because that comment becomes part of a green or a red dot doesn't mean you shouldn't take it seriously. Had the same comment being written as a post, wouldn't that have looked bad? Wouldn't that have been violation of one of the laws of Daniweb? Yes, that sure would have been.

And as far as applying the bad word filter is concerned don't you think "Dude, what the fu** is a ****** like you doing in this forum? Just eat some sh** and get the f*** off." is very much capable of conveying the message? Just because someone doesn't give a damn doesn't mean that all of Daniweb members should adopt a thick skinned attitude.

By allowing such things to pass by in the form of reputation comments, you leave a big gaping hole in the entire system of 'Keep it pleasant'.

darkagn commented: I couldn't agree more! +1
Sulley's Boo commented: hum aap se sehmad hai :P .. i hope i got it right :cool: +3
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Please don't post "spam" or "Thank you" posts in this thread since this is meant to be used as a guide for all beginners and I am sure we would like it to be on topic. I hope you understand this.

» Introduction to Java «

To start off, Java is a general purpose programming language liked by application developers and web developers alike. It is the force which drives a large number of enterprise applications out there. Read more about it here. And yes, just for the records, Java is not slow!! [ 1 , 2 , 3 ] ;-)

» Getting started «

All you require to develop Java application is a text editor and a JDK which encompasses a Java compiler, a Java Virtual Machine and a host of tools which ease your development. Some handy links (ignore the specifications for the time being):

» Java 8 Download
» Java 8 online documentation
» Java 8 Language Specification
» Java 8 Virtual Machine Specification

After installing the JDK, you might want to take a look at the common problems beginners face when setting up Java and their solutions.

As a beginner, you should know the commonly used JDK development tools like javac, java, jar, javadoc to name a few. Read about them here.

There are a lot of IDE (Integrated Development Environments) …

Black Box commented: The java forum was in need of a document like this one, great work. +1
Ezzaral commented: Many thanks. We've needed this for awhile now :) +4
John A commented: Good work, my friend. +12
tux4life commented: Great stuff here. +13
Megha SR commented: thankyou for this useful information +1
PythonNewbie2 commented: Good starting Java guide. +2
Anuradha Mandal commented: Good post. +0
DJSAN10 commented: great help for beginners.. thank you +2
Mihujoy commented: Thanks for the nice startup tutorial! ~Mihujoy +0
jackbauer24 commented: Good job! :) +3
stultuske commented: Hail to the King :) +14
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Why does the JVM initialise the data fields with default values
AFAIK, design decision by the language implementors. Also makes sense since I wouldn't want the members of my newly created instance to have a value of 'undefined'.

> What is the need for such a procedure of calling the default constructor?
Instances in Java are created by the invocation of a series of constructors. The first line of each constructor is a call to it's superclass's constructor except in the case of 'Object' class. If Java doesn't provide a default constructor, it would become necessary for the programmer to specify a default constructor for each class so as not to break the constructor chaining mechanism and thereby the language specification.

Jishnu commented: Thank you! +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I don't claim to possess a solution, but lets analyze it this way.

There has to be a reason for each and every post made, a motivation for an expert to post on the forums. Let's come up with a few of them.

Money
Yes, money. Money makes the world go round and is one of the factors which might drive some experts to take part in your forums. But I guess this trick has already been tried out with the blogging competition without any visible success. And I don't think any of the moderators / contributors here need that kind of money or do it for money. The core members contribute for the sake of Daniweb and not for some other ulterior motive (at least me). ;-)

Freedom
One of the finest examples of the best kind of forums out there is 'Google groups'. The people who render help there know the subject under consideration like the back of their hand. So what is so special about those groups? Freedom. No obligation to follow any rules. They are free to go off-topic. They are free to say 'STFU' to any poster and get away with it, no issues as such. Or maybe they are just comfortable with newsgroups. Who knows?

Another contender here is Devshed. AFAIK, Devshed has been around for longer than Daniweb, from a time when forums were not in abundance. Maybe it has got some of it's member because of …

Dani commented: Good post. Thanks. +31
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Happy Diwali to all the members of Daniweb. Wishing you all a shining and prosperous year ahead. :)

Regards,
Sanjay.

thunderstorm98 commented: Thanks +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Oh my, still eating food and drinking water.

joshSCH commented: TROLL!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +12
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> at url http://lowellbonnell.ca/index.php?view=Markets my ajax will only work if you insert the
> www in firefox. IE is fine either way.
This is because the browser thinks you are trying to do XSS.

iamthwee commented: *nods* +13
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The prompt function returns a string. The switch construct and so also your calculations requires product be a numeric value. Convert the user input returned to a number before using it.

do
{
   product = Number(prompt("Enter something"));
   if(isNaN(product))
      product = -1;
   switch(product)
   {
      case 1: price = 1.0; break;
      /* and so on */
      default: price = 0;
   }
   total += price;
} while(product != 0);

Don't use document.write(). It's far from flexible. There are better ways of dynamically or programatically appending content to your document, known as DOM manipulation.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Still eating food and drinking water.

Chaky commented: I should ask you he same, he he. I guess it qualifies as "food". +4
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> How can I get certain html text input fields to appear disabled, and the text that's inside
> un-editable or unchange-able?
You have got to realize that 'disabled' doesn't mean or equate to 'readonly'. Both these properties disallow the user from editing the entered text but the real difference comes when you try retrieving the form element values at the server. If the element is marked with the property 'disabled', the form element value won't be submitted to the server while a form elements' value marked 'readonly' will be. <input type="text" name="txtName" id="txtName" readonly="readonly" /> <input type="text" name="txtName" id="txtName" disabled="disabled" />

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> He made Boo mad. He should apologize. He was insulting, not funny.
Agree with you on all counts, that _was_ mean. Plus lack of apology makes it look even worse. It's a pity many people take apologizing an inferior act... :icon_frown:

Sulley's Boo commented: *hugs him real tiiiiiiiiiight* :D +3
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Yes, someone please smear some cake on Chaky's face. ;-)

Chaky commented: *Takes the cake, sneaks behind him and gives him a cake-slap-in-the-face from behind*.... you have some too, hehe +4
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Eating food and drinking water.

Sulley's Boo commented: are wah! hum samjhe ke tu lokhand khata .. demagh jo itna taiz hai :P +3
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I know this is a little late, but if you live in the US, switch to law and join the money making crowd. In your present technical field you will always be just a peon competing with low paid labor from India or China.

If you are the best, nothing prevents you from being what you want to be / achieving what you want. Of course, if someone is a lazy potato who somehow manages to get a 'engineering' degree by stealing someone elses' work, he deserves to be a peon.

Sulley's Boo commented: riiiiiiiiight! +3
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> From your phrase i consider that you don't know anything from graphics.h
You are correct, I don't use kiddie stuff unless forced to do so. Real people use real graphics API like OpenGL and DirectX.

Sturm commented: lol "real people use real graphics API" +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

We are really happy to hear that after two months of this threads' inactivity... ;-)

Duki commented: HAHAHAHAHHAAHHAHAHAHHAHAAHAHAHAHAHAHAHAHAHAAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHA LOLOLOLOLOLOOLOLOLOLOLOLOLOLOLOLOL +4
Rashakil Fol commented: mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmkay +6
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> window.location = imageArray[ i - 1 ].href; window.location is an Object , its href property a String . Though the above one works, the correct way of writing it would be: window.location.href = imageArray[ i - 1 ].href;

itsjareds commented: window.location vs window.location.href is good :D +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Maybe this would help.

peter_budo commented: Nice one. I didn't know I can add APPLET that way +4
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

"If one sees a giant, it is recommendable to examine the position of the sun first to see if it is not the shadow of the pigmy."

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> no i disagree, it doesn't take long to edit each post.
I disagree. I absolutely refuse to add code tags to posts of those members who have been already warned a number of times. Maybe you have a lot of time firing up your favorite IDE, indenting it and reposting it -- many don't.

> Newbies should not be blamed for their stupidity.
Stupidity yes, casualness and carelessness no. And come to think of it, this thread has been started keeping exactly these kind of people in mind who never bother using code tags.

> We don't want to ignore them, we want to help them.
Help begets help. If someone ignores me repeatedly, I would probably do the same.

And last but not the least, I completely am in favor of a script which reminds the newbies to use code tags along with the link to the page which shows how to use code tags. Considering that they won't be able to make their post, they would definitely consider reading the announcements more carefully. But considering most people block scripts from sites, a client side script won't do the job...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Now for something which is thought provoking and on topic....

A real life story from Seoul

My mom only had one eye. I hated her... she was such an embarrassment. My mom ran a small shop at a flea market. She collected little weeds and such to sell... anything for the money we needed she was such an embarrassment. There was this one day during elementary school.
I remember that it was field day, and my mom came. I was so embarrassed.
How could she do this to me? I threw her a hateful look and ran out. The next day at school..."Your mom only has one eye?!" and they taunted me.

I wished that my mom would just disappear from this world so I said to my mom, "Mom, why don't you have the other eye?! You're only going to make me a laughingstock. Why don't you just die?" My mom did not respond. I guess I felt a little bad, but at the same time, it felt good to think that I had said what I'd wanted to say all this time.

Maybe it was because my mom hadn't punished me, but I didn't think that I had hurt her feelings very badly.

That night...I woke up, and went to the kitchen to get a glass of water. My mom was crying there, so quietly, as if she was afraid that she might wake me. I took a look at her, and then turned away. …

vinod_javas commented: awesome! +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

"A man who doesn't embrace his past has no future."

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Bench has given a good suggestion. But if you are not allowed to use maps, try using two parallel string arrays in which the location of the name of the animal and its description resides in the same location in their respective arrays.

const int SIZE = 3;
string animal[SIZE] = {"dog", "cat", "pig"};
string desc[SIZE] = {"bark", "meow", "oink"};

bool found = false;
for(int i = 0; i < SIZE; ++i)
{
    if(animal[i] == input)
    {
        cout << animal[i] << " -> " << desc[i];
        found = true;
        break;
    }
}
if(!found)
    cout << "No such animal exists";

I know this looks like a lot of work for a single user input, but is just another way of doing things, plus this is much more flexible approach instead of the hard-coded 'if...else' or 'switch' constructs. Since you are under going a programming course, I guess the focus would be more on logic and uniqueness than efficiency.

Killer_Typo commented: great idea! +6
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Mauro, more than 30 posts and you still don't use code tags?

Bench commented: Some people just never get it... +3
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Why?
Answer.

Bench commented: Good link, would have saved me the typing. +3
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Well, except for that very last person - they would probably still have one eye...
You the overlook the possibility of simultaneous eye stabbing.

sergent commented: lol +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

"An eye for an eye makes the whole world blind."

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Get a good video player like VLC or MPStar. If the files still don't work, they must be corrupted.

sk8ndestroy14 commented: Thanks. +8
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

"Science without morals is a curse."

codeorder commented: :) +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> can anyone suggest me on how to remove the duplicate sequences from being displayed/generated
By using a better algorithm like 'Heap Permute'. See this. Though the solution is in C++, with almost no effort, you can port it to Java.

iamthwee commented: retarded... -2
Aia commented: Are you saying that as you look at the mirror? +6
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Is it too late to join the tournament?
Nah, just jump in the fray. Write a PM to the admin if these people don't let you in. ;-)

ndeniche commented: lol +3
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Dump the loops, what you need is a recursive algorithm which would work for arbitrary lengths of arrays. One of the way is using 'Heap Permute'. Here is a sample program which you can easily adapt to use with C style strings:

// Untested

const int SIZE = 4;
static int counter = 1;

void swap(int arr[], int one, int two)
{
    int tmp = arr[one];
    arr[one] = arr[two];
    arr[two] = tmp;
}

void print(int arr[])
{
    for(int i = 0; i < SIZE; ++i)
    {
        cout << arr[i] << "  ";
    }
    cout << " ------->  " << counter++;
    putchar('\n');
}

void permute(int arr[], int size)
{
    if(size == 1)
    {
        print(arr);
    }
    else
    {
        for(int i = 0; i < size; ++i)
        {
            permute(arr, size - 1);
            if(size % 2 == 1)
                swap(arr, 0, size - 1);
            else
                swap(arr, i, size - 1);
        }
    }
}

int main()
{
    int myArr[SIZE] = {1, 2, 3, 4};
    permute(myArr, SIZE);
    cin.get();
}
Killer_Typo commented: a very smart man indeed +6
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Damn, someone bad rep Rash for me as I have to spread some around first..
I have given him enough good points to last for 2-3 rounds... ;-)

joshSCH commented: Damn your rep power. I would bad rep you, but I'm afraid of the consequences :) +16
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Here you can get a (prepaid)plan for as cheap as $1 which allows you to make calls for total worth of $0.8

arjunsasidharan commented: That's rite.. Its cheap. But indian's find it a little expensive ;) +3
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Yes definitely, they should get a good smacking when needed. Smack smack smack...

Aia commented: Make sure you don't leave marks. ;) +6
Rashakil Fol commented: Leave marks on the face, like a good dude. +8
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You end up removing the fourth character instead of the third one. Doing if(i % 3 == 2) would solve the problem.

But I still think that removing third character from each _word_ is different from removing third character from the string as a whole.

Hello World
Helo Wold
Heo Wod
He Wo

Killer_Typo commented: oops thanks for fixing my mistake! :o) +5
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Well, it's summer so no school for most people
Oh yeah, and here it is raining so heavily, I feel as though this is my last post. ;-)

iamthwee commented: We can only hope... -2
joshSCH commented: Happy Independence Day! :p +15
arjunsasidharan commented: iamthewee is such a pain in the butt +3
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Nice work. Keep up the good work guys. If this event goes successful, maybe you should come up with more such creative ideas in which Daniweb members can participate.

At least this would liven things up a bit around here, since Narue is under the impression that she is the only one who can do that by living up to her title... :-)

sk8ndestroy14 commented: Thanks for the support. +6
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Here is something for those people who think that 'Teach yourself xxx in yy days' can do them any good..

iamthwee commented: I agree, even the the teach yourself in so many hours books are much better! +11
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> However I thought that behavior underfined ment that the compiler
> doesn't know what to do, therefore it would not compile.
You are getting confused between the two of them. Using clrscr() is what constitutues non-portability since it is available only on Borland Compilers and is not a part of the language standard. In other words, change in the architecture, compiler or OS might result in the code not being able to compile.

Undefined behaviour is when people say '..but it works for me'. Returning an address of the local variable and using it is what constitutes undefined behaviour since the memory no longer belongs to the programmer. If you write such code, you are completely at the mercy of the runtime if it decides to use up the memory which was used by your local variable.

int fflush(FILE* stream); Flushes stream stream and returns zero on success or EOF on error. Effect undefined for input stream. fflush(NULL) flushes all output streams.

> where is it used and can you please explain it with a sample code
> where it is used
Output in C is normally buffered, which means that the output is not written character by character but in chunks. It might so happen that a printf statement you wrote never got printed since the code after it caused a segmentation fault. In that case you can force the output to be printed …

Aia commented: Thank you. What else can I say?. +5
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

No, explode.

Aia commented: Oh no!, we all are going to die.... someday. +5
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Is your avatar a pic of your son?
No, he is Dave. :D

PS: Sorry Dave couldn't resist it.

Dave Sinkula commented: Danke +11
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Not more than 25 I guess...

joshSCH commented: Close.. 23. I think even I give more than that ;) heh jk +13
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

But seriously, I can't stand kids who call their mother 'bitch'. Maybe after a few years when you will have a real family, you would see things in a different light...

christina>you commented: Completely agree! +18