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

> But where should I start?
If game development, C++ all the way. Of course once you grow with C++, you can move to Windows programming, scripting, DirectX or OpenGL, the core technologies required for game development.

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

> I like it a lot and does everything that you are complaining about in the quote above.
Of course it supports all of it AD, every commercial game out there has been supporting those _long_, time back.

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

Here is a quick and dirty way of doing it. It should suffice your purpose, but I must warn you that any kind of validation done at client side is moot, pointless. Validation at the server is what you must go for unless its an intranet application with limited target audience who can be absolutely trusted.

<!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">
<head>
<meta name="generator" content="HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org" />
<title>sample page</title>
<script type="text/javascript">
//<![CDATA[
    function verify(frm)
    {
        var element = document.getElementById('txt');
        if(isNaN(new Number(element.value)))
                element.value = element.value.substring(0, element.value.length - 1) 
    }
//]]>
</script>
</head>
<body>
<form action=""><input type="text" onkeyup="verify(this.id);" name="txt" id="txt" /></form>
</body>
</html>

PS: This implementation allows spaces which shouldn't be a problem as such. If you still think you are going to have problems, just trim the value. Also this implementation is not the best of its kind. I can come up with an optimized implementation which uses events to detect which key has been pressed but its more pain in the neck than it's worth...

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

This notification thing is killing me. Even when I click on those threads _again_, they still refuse to move out of my CP. Any idea WTH is going on?

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

It would be better if you declare Quintoncoert as the winner as of now and start a new competition. There are many people out there who are waiting for their turn to participate in the coming competitions. Waiting would be doing them injustice.

Just start a new competition already...

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

Have you tried simply removing the "-" characters from those three lines? Some XML Parsers (possibly Tomcat's included) are a little picky.

Methinks he directly copy pasted from the XML opened in IE and hence those dashes.

Staneja, did the XML file provided by me not work? I have seen a lot of bug reports lying around here and there regarding the same problem. The same XML file works fine for me.

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

This is a bit roundabout way but should get the job done in a cross browser compatible manner.

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

Maybe something like this?

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

Or something like this. Works in IE, FF and Opera.

<html>
<head>
    <script type='text/javascript'>
    var CONST = 'myname';
    function doSomething(frm)
    {
        for(var i = 1; i < 4; ++i)
        {
            var txt = CONST + i;
            document.frm[txt].value = 'Test';
        }
    }
    </script>
</head>
<body>
    <form name="frm">
        <input type = 'text' name = 'myname1' /><br />
        <input type = 'text' name = 'myname2' /><br />
        <input type = 'text' name = 'myname3' /><br />
        <input type = 'button' onclick = 'doSomething(this.form);' value = 'Do' />
    </form>
</body>
</html>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

See this sample snippet:

<html>
<head>
</head>
<body>
    <form name="frm">
        <input type="text" name="txt" value="Hello" />
        <input type="button" onclick="this.form.txt.readOnly = true;" value="Disable text field" /> 
        <input type="button" onclick="this.form.txt.readOnly = false;" value="Enable text field" />
        <br /><br />
        
        <input type="button" value="My Button" name="btn" /> 
        <input type="button" onclick="this.form.btn.disabled = true;" value="Disable button" /> 
        <input type="button" onclick="this.form.btn.disabled = false;" value="Enable button" />
        <br /><br />
        
        <select name="mySelect">
            <option value="india">India</option>
            <option value="america">America</option>
        </select>
        <input type="button" onclick="this.form.mySelect.disabled = true;" value="Disable drop down" /> 
        <input type="button" onclick="this.form.mySelect.disabled = false;" value="Enable drop down" />
    </form>
</body>
</html>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You still haven't told us your Tomcat version..

But still, try out this xml file format:

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">
<web-app>
    <display-name>Hello, World Application</display-name>
    <description>
    This is a simple web application with a source code organization
    based on the recommendations of the Application Developer's Guide.
    </description>

    <servlet>
        <servlet-name>hello</servlet-name>
        <servlet-class>servlet1</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>hello</servlet-name>
        <url-pattern>/goHello</url-pattern>
    </servlet-mapping>

</web-app>

And run it using: http://localhost:8080/your_root_dir_name/goHello

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

You just need to add the JConnector jar files to your application class path. If still in doubt, try out this tutorial (untested).

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

'Hey, I am not here seeking ready made code.'

"I did try my best.'

'Our teacher sucks, she doesn't teach us anything'.

'The above code is working fine except a small problem.'

'I love my clients, they are so co-operative.'

'My project manager is really a nice guy.'

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

> Initialize min variable with zero and do this min checking in the same loop where user provides inputs;
What happens when all the inputs are greater than 0? You end up getting zero as the minimum which is the wrong answer.

To get around that, you would have to use a modified version of the loop as:

int min = 0;
for(int i = 0; i < 5; ++i)
{
    // accept input in 'num'
    if(i == 0)
         min =   num;
    else if(num < min)
        min = num;    
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Instead of sorting the array just to find the minimum, loop though the array continuously updating the 'min' variable. Something like:

int min = myArray[0];
for(int i = 1, limit = myArray.length; i < limit; ++i)
{
    if(myArray[i] < min)
        min = myArray[i];
}
System.out.println("The minimum is " + min);
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

If you are by any chance attaching or calling the validation function to the 'onclick()' event of the 'submit' button, you need to return a value from the validation function to prevent the trip to the server and to make the data in the form fields persist.

<html>
<head>
    <script type="text/javascript">
    var SOS = {};
    
    SOS.validate = function(myForm)
    {
        var returnCode = true;
        if(myForm.elements['txt'].value.length == 0)
        {
            alert('YOu need to enter something');
            returnCode = false;
        }
        return(returnCode);        
    }
    
    </script>
</head>
<body>
    <form action="./Servlet?QueryString">
        <input type="text" id="txt" name="txt" />
        <br />
        <input type="submit" onclick="return SOS.validate(this.form);" />
    </form>
</body>
</html>

Of course I would like to point out here that client side validation sucks and are of no value whatsoever. Real validations are done at the server. The javascript executing on the client is entirely at the mercy of the person sitting in front of the computer on which it is executing, and so client-side code provides precisely zero security.

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

You should atleast have pasted the 'stack trace' for us to help you out. The code as such looks OK. Paste the stack trace and the way you are trying to execute the WAR file.

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

Bah, spammer to the core. :)

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

'I would never do that, would I?'

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

There is no cross compliant direct equivalent of window.openPopup() method. Its IE only.

If you want to emulate the behavior of 'window.openPopup()', use 'window.open()' along with any 3rd party Javascript Drag and Drop (D&D) API.

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

> We all have to believe something, right?
How about believing in yourself?

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

A static method implies a class level method (as opposed to the instance methods) while a static variable implies a class variable. All instances of that class would share the same copy of the variable. If you want your 'HashSet' to be 'free from changes', make it final.

Also keep in mind that the Hashset doesn't allow duplicates, if thats what you are looking for...

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

Whatever gave you the idea those two things were related...

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

You need to enter the reference to the newly created pages in an array which is kept in the main page and use that array to loop through the window references and close them.

Something like this:

[B] Main.html[/B]

<html>
<head>
    <script>
    var wnd = new Array();
     function openit(id)
    {
        if(!wnd[id] || wnd[id].closed)
            wnd[id] = window.open("Child.html");    
        else
            wnd[id].focus();
    }
    
    function closeEverything()
    {
        for(var i = 0; i < wnd.length; ++i)
            wnd[i].close();
    }
    </script>
</head>
<body>
    <form>
        <input type="button" value="Open1" onclick="openit(0);" /><br/>
        <input type="button" value="Open2" onclick="openit(1);" /><br/>
        <input type="button" value="Open3" onclick="openit(2);" /><br/>
    </form>
</body>
</html>

[B] Child.html[/B]

<html>
<head>
    <script>
    function closeAll()
    {
        window.opener.closeEverything();
    }
    </script>
</head>
<body>
    <form>
        <input type="button" value="Close Me" onclick="window.close();" /><br/><br /><br />
        <input type="button" value="Close all children" onclick="closeAll();" /><br/>
</form>
</body>
</html>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

There is no direct replacement of window.createPopup() function as far as I know. Its an IE function only. But I don't see what kind of functionality you require which can't be satisfied by the window.open() function?

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

> I want to close the frameset window. It is not a frame.
Do you know what you are saying? Frames are defined in the frameset tag and without frame tags, frameset is of no use. So how is that "its not a frame"?

Paste the working example and maybe then it would be easier for us to render help.

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

Use top.your_frame_name or window.frames to get the frame reference.(here top is the global window object).

Read this for more information about DOM.

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

Paste the code which causes the 'NumberFormatException'. As far as the constraint imposed by the primitives is concerned, read up on Biginteger.

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

Here you go MS Boy... :-)

<html>
<head>
    <script>
    function boundDim(oObject)
    {
        var oTextRange = document.selection.createRange();
        if (oTextRange != null) {
            alert("The bounding left is \n" + oTextRange.boundingLeft);
            oTextRange.pasteHTML("<b>" + oTextRange.htmlText + "</b>");
        }

    }
    </script>
</head>
<body onclick="boundDim(this);">Hello to all. Hello to me.</body>
</html>

The above is just a small example on what you can do with the API. Once the text is selected, you get its offset in pixels which you can then use to distinguish between the first and second foobar.
If my snippet doesn't give you what you need, also read on selection and range.

Do let me know if it works. :)

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

Maybe you would even like to read this.

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

> While I did say 10, not 5, I do believe I said something about it.
Actually a PM to Dani for such critical things is the most logical thing... I have myself PM'ed her twice regarding the way code tags behave with Javascript code.

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

> Especially with Huggy Bear coming up so often.
I guess you must be associating 'Huggy bear' with weird things...

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

If you really want to learn, stop attempting those questions and start off here. Just keep pressing 'Next' and you would be good to go.

You first need to know what you are dealing with before diving in head first. The good thing about the tutorials is that they have exercises at their end with answers for you to gauge what you have gathered from the material.

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

> Hi, I'm looking for a good program writing tools C++, have any suggestions?
What exactly do you need? As Jwenting pointed out, your question doesn't make sense. Do you need some kind of software to speed up your development time or C++ development tools?

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

Something like this and this?

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

Glad you could get new ideas by discussing the situation with me. :)

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

> Lots of posts means they must be doing something right..
Post count doesn't convey anything. Its just a measure of how much free time you spend with Daniweb, thats it.

The process of finding out how much a person is worth is pretty much complicated and subjective. :)

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

AFAIK, Firefox always had problems with supporting the 'attachEvent' function which works properly in IE and Opera.

Try something like: aShow.onactivate = kiosk; This code would work in all browsers. And I am pretty sure that only IE supports something like 'onactivate' since it doesn't seem to be a standard event. Maybe 'onfocus' would be more like it but them again I haven't really tried it out.

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

I highly doubt anyone would do such a thing.. What would be the purpose? Simply to gain reputation in the community? I'm quite certain that such activity could be easily monitored. If some random person that no one has ever heard of before all of a sudden has 700 rep points, then perhaps that member should be investigated for 'fraud' by the admins. It would not be hard to catch people doing that, and I doubt many would anyways.. We are just talking about small points (like 1-5) for new members.

I can very well create dummy accounts, make them ask simple questions, answer those questions and gain a nice and green 5 point reputation without any effort. How's that? And please don't be under the assumption that such a minor thing would be noticed by anyone because it won't.

But on the contrary, you have to ask yourself what is the purpose of an IT community such as this? The reason for its very existence is to help one another... to share our knowledge, and in return be taught something ourselves. So, the new members should be allowed a voice in the community. If any Daniweb member helps another with a problem, be it little or small (what does it matter? That member was stumped and needed help.. it shouldn't matter whether the problem seemed idiotic to the tech gurus) then the member who donated his time and knowledge should be rewarded. The rep system should not be …

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

> Of course you do know something about computers! If you don't
> then how in the world are you posting on DaniWeb
I think he meant it 'The programming language' way, though I completely agree with you. :)

> Before you know it you will become as good as most other posters
Again agreed with you. Before you run, you must learn to walk. If you don't try it out, you reach nowhere.

And BTW sk8, of all the times I have read your no nonsense and witty replies, I am sure you are not the "duh, what's a compiler" type. :)

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

The 'clearInterval()' cancels the timer and not the function. Its like a kid going down a ride again and again. Once he is told not to do it again, sure thing, it doesn't happen again, but that doesn't mean his existing ride is canceled in the middle. And I see no such thing as you mention in the documentation.

This code works like a charm in IE, FF and Opera.

<html>
<head>
    <script type="text/javascript">
    var hnd;
    
    function doSomething()
    {    
        hnd = setInterval("calculate()", 2000);
        var d = document.getElementById('d');
        d.innerHTML = "Hello to all. My name is <b>sos.</b>";
    }
    
    function calculate()
    {
        clearInterval(hnd);
        for(var i = 1, sum = 0; i <= 1000; ++i)
            sum += i;
        alert("1 + 2 + 3 + .. + 1000 = " + sum);
    }
    </script>
</head>
<body onload="doSomething();">
    <div id="d"></div>    
</body>
</html>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You are under the wrong impression that you get repped by people only if you help them. Many established members of this site rep people for good replies. Even I rep many people in C/C++, Java, Javascript forums so it doesn't mean they answered my questions. Its just that they put across a valid, useful and helpful answer.

I guess thats the real meaning of reputation i.e. having a reputation in the eyes of the ones who understand the real meaning behind it.

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

Read the previous post. It answers all your questions. The only thing you need to do is write the factorial function.

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

Write a separate helper function 'factorial()' which would calculate factorial of any number passed to it. Call that function from the 'factorialSum()' function.

private long factorial(int num)
{
    //code here

    return(result);   //possibility of overflow
}

public long factorialSum(int a, int b)
{
    //code to check the validity of inputs

    long first = factorial(a);
    long second = factorial(b);
    return(first + second);   //possibility of overflow
}

You have got to realize here that factorials grow exponentially and quickly get out of hand so using finite data types like long or int won't serve you any good. But I am pretty sure that is not what the exercise stresses on, so for the time being just concentrate on getting the logic and syntax correct.

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

> I am also doing java and I am just wondering what its uses are in webdesign apart from game creation?
J2EE can be used for creating rich, easier to maintain, modular dynamic web applications. The advantage is that you don't need to learn a new language just to develop web applications. Your existing knowledge of java with a bit of practice will make you comfortable with the technology.

Java offers separation of the presentation, the business logic and the data access logic, a thing you won't see much in PHP built sites.

> It seems to slow to be used to create dynamic webpages
Slow? In what sense? Does this site look slow to you? Look at the business world around you and you would find most of the financial, banking and business critical sites are made using Servlets / JSP / EJB's. Also there are a lot of mature frameworks for Java which facilitate rapid development, something you would not find for PHP.

Oh and BTW, MySQL is a database while Java is a programming language and yes, you can create databases using Java.

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

> setIinterval is like a repeating time bomb, not a pause function.
If you know how to tame it, then yes, its of much use, not a time bomb.

>But it kept repeating the long calculation, and it got the calculations wrong too.
Before starting the timer or calling the setInterval() function, check if the 'hnd' is defined or not. If 'hnd' is undefined, you already have the timer running so no need to start it again, if not, then start the timer.

if(typeof(hnd) != 'undefined' || hnd)
{
    setInterval("function()", 1000);
}

// [B]OR[/B] clear the timer as soon as you enter the doButton() function

function dobutton1(a,b,c,d,e){
  clearInterval(hnd);
  var l1, l2, maxa, max1, max2;
  for(l1 = 0; l1 < d; l1++){
    for(l2 = 0; l2 < e; l2++){
      calcgrid(a, b, c, l1, l2);       // this function takes time
      checkgrid(a, l1, l2, maxa, max1, max2);
    }
  };
  putgrid(maxa, b, c, max1, max2);
};
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

AJAX is required only when you need some kind of asynchronous interaction with the server without spoiling the user experience(i.e . without page reloads). So do you need this progress bar just for eye candy or does it have anything to do with the server being busy or something like that?

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

The more I think about it, the more I feel that using AJAX (if possible and permitted) is the way to go, though I am assuming that your application is not just an eye candy one which does no real work at the server.

AJAX is asynchronous (though you can make in synchronous, which is not of much help). This asynchronous nature helps the user is continuing his task while you do your time intensive processing at the server.

Also, is the user allowed to press multiple buttons or is it assured that only one button at a time would be pressed till the end result and processing finishes?

Once the loop starts, do the values of variables 'a', 'b', 'c', 'd' etc. change or remain the same as they were when the control entered the function?

But still, considering the checkgrid and the putgrid functions require the values from the computation of calcgrid() function, I don't think delaying the execution of calcgrid() would be of any use...

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

^
A CEO of the company he would someday establish. :)