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

A form is by default submitted when you press the return key. You need to show us how your form is structured so that we can offer more suggestions. Paste your code here with code tags.

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

> Am I right?
Yes, you can have nesting of arbitrary depths as long as it follows the key-value pair format where key is always a string and value can be either a string, number, array, another object, true, false or null.

> And how would I go about to access these values from codebehind? (ASP.NET)
Take a look at the .NET binding for JSON.

~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

Or start giving warnings to those who do it.

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

Look into JSON for shipping data back and forth between your server and Javascript. It has become a de-facto standard like XML for shipping data in a platform / language agnostic manner.

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

First of all you should report the post in consideration so that the entire mod team have a look at it and decide whether it violates the site rules or not. With a lot of these things going around lately, I am sure there would be something definite coming out of this.

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

Again, with URL rewriting and redirection, those file extensions and URL's don't mean anything. I can very well have a page with url http://www.mysite.com/do.sos and serve a static page called index.html to the client.

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

> you dont actually see the page interacting with the javascript so it would technically be a html
> page
Every page served to the client technically has a content type of 'text/html'. The dynamic nature is due to the merit of the form element being able to post its data to a remote resource specified by it's action property, which is capable of processing that data.

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

Then the only option left would be to debug your script and see what exactly is causing the 'undefined' problem. A quick google search for IE debugging can give you some leads.

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

If you are using IE7, this post might help you in some way.

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

> but both of the child windows the parent is same.
No, this isn't the case.

> when i open the first child window then the parent should be disable .when i close the first
> child window then the parent window should be enable

<!-- s.html -->

<html>
<head>
<title>s.html</title>
<SCRIPT >
my_window = null;
function popuponclick() {
	my_window = window.open("p.html","myP", "status=1,width=750,height=450,resizable=no,modal");
}

function check() {
	if(my_window && !my_window.closed)
		my_window.focus();
}

window.onload = function() {
	window.name = "s.html";
}
</script>
</head>
<body onclick="check();" onfocus="check();">
<p>
<a href="#" onclick="popuponclick();">show popup window</a>
<br />
<a href="#" onclick="window.close();">close popup window</a>
</p>
</body>
</html>
<!-- p.html -->

<html>
<head>
<title>p.html</title>
<script language = javascript>
my_window = null;
function popuponclick()
{
	my_window = window.open("w.html","myW", "status=1,width=750,height=450,resizable=no,modal");
}

function check()
{
	if(my_window && !my_window.closed)
		my_window.focus();
}

window.onload = function() {
	window.name = "p.html";
	alert("Parent of p.html: " + opener.name);
}
</script>
</head>
<body onclick="check();" onfocus="check();">
<p>
<a href="#" onclick="popuponclick();">show popup window</a>
<br />
<a href="#" onclick="window.close();">close popup window</a>
</p>
</body>
</html>
<!-- w.html -->

<html>
<head>
	<title>w.html</title>
</head>
<script type="text/javascript">
window.onload = function() {
	alert("Parent of w.html: " + opener.name);
}
</script>
<body>
<p>
<a href="#">show popup window</a>
<br />
<a href="#" onclick="window.close();">close popup window</a>
</p>
</body>
</html>

Though the above code works, it has some major problems.

◄ All the above files have a DOCTYPE declaration missing which is a bad thing causing the browser to go in quirks mode.
◄ Instead of directly attaching event listeners …

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

Someone's in deep deep trouble. ;-)

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

Read this.

As far as your problem is concerned, document.data_entry.topic.options(document.data_entry.topic.selectedIndex).text; should be document.data_entry.topic.options[document.data_entry.topic.selectedIndex].value ;

The above way of referencing form elements is pretty inefficient and partly incorrect which is what the tutorial I posted aims at explaining.

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

It is working for me which means you are doing something wrong. Post the updated code with code tags. Read the announcements and site rules to know about them without which getting help might be a bit difficult.

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

Solved. ;-)

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

> This is a not as messy solution
Your solution doesn't address the two things asked in your assignment. For one "Use a sentinel value to signal the end of input." and "After two chances, quit reading input".

You need to reset the tries counter after the user recovers from his mistake so he can get three consecutive attempts to enter a bad value. And what happens if he wants to just *stop*? You leave him no choice but to enter some junk characters three times in a row. This is one of the reasons why you were asked to keep a sentinel controlled loop.

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

Something simple like this would have done the job:

public class Test
{
    public static void main(String[] args)
    {
        int tries = 0;
        boolean isNormalTermination = true;
        final int LIMIT = 3; 
        final float SENTINEL = -1.0f, TOLERANCE = 1e-6f;
        float val = TOLERANCE, total = 0f;
        Scanner in = new Scanner(System.in);
        do
        {
            try
            {
                System.out.print("Enter a float value: ");
                val = in.nextFloat();
                total += val;
                tries = 0;
            }
            catch(InputMismatchException e)
            {
                in.skip("\\w+"); //gobble up the junk characters
                ++tries;
                if(tries == LIMIT)
                {
                    isNormalTermination = false;
                    break;
                }
                System.out.println("Error! Please try again.");
            }
        }while(TOLERANCE < (Math.abs(val - SENTINEL)));
        in.close();
        if(!isNormalTermination)
        {
            System.out.println("You have exceeded " + LIMIT + " tries. Sorry");
        }
        System.out.print("Total: " + (total - SENTINEL));        
    }
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Attach a function to the onclick and onfocus event handlers which would do something like this:

function focusChild()
{
    if(my_window)
        my_window.focus();
}

Here my_window is a global variable which holds the reference to the newly created popup window. It follows that as long as the child window is alive it will the one given focus.

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

» You can't use the <body> tags when using <frameset> tags. Remove those from your main.html » You are referring to the frames in a wrong manner. Use the 'top' property of the window object to refer to the parent window. You can then access the frames using top.frames['frameName']. » For your document.write to write to the desired frame and not the current frame, use the target property of the <a> tag and set it to the frame you want. Something like: <a href="#" target="right" onclick="something();">Linky</a> » <title />State Statistics</title> is an incorrect way of writing the <title> tag.

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

r5ing:

A few things:
» Don't use scanf or it's non-standard variants for accepting user input. There are better ways of achieving it. Read this.

» The way you expose the interface doesn't seem to be right. Make encode() return a char array instead of nothing.

» Also since Morse code is case insensitive you might consider converting the user input to uppercase before applying encode function to it.

> char *ch;
> printf("please enter char to convert to morse: ");
> scanf_s("%s", &ch);

How do you expect this to work? You are assigning the string entered by the user to something which doesn't belong to you. You need to allocate enough memory. Something like char ch[BUFSIZ] = { 0 }; Plus scanf requires you pass the starting address of the memory location. Since ch itself is a char array you just need to pass ch instead of &ch .

~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

In a layman's terms:

J2SE stands for Java 2 standard edition and is normally for developing desktop applications, forms the core/base API.

J2EE stands for Java 2 enterprise edition for applications which run on servers, for example web sites.

J2ME stands for Java 2 micro edition for applications which run on resource constrained devices (small scale devices) like cell phones, for example games.

Netbeans is an IDE (Integrated development environment) developed in Java which eases your job of application development.

And yes, Java is free and open source.

Google is your friend.

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

Just convert the given boolean array to an integer array by looping through the contents and pass it to your existing function.

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

> Can we use static nested classes practically?
Look at the source code of the 'Entry' inner class of 'HashMap'. The source can be found in the JDK directory in src.zip.

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

> So, by now it seems like C++ will be the futures programming language.
I was expecting something along the lines of Java or C if you are going by popularity though it would be nice to know the source of your conclusion.

> Write down every thing about programming language that pops up on your mind!
You mean this?

> But what do you think of the future of programming languages??
They would be good at hiding complexities from the developer, complexities which don't concern the developer or the solution achieving process as whole.

> COBOL and Fortran are still hugely popular in their respective fields
That would be not by choice. :-)

> I don't mean to reply rudely, but C++ is a terrible programming language, a complete mess.
It doesn't seem right to look at a tool which you used to use and say that. Just acquiring some new tools doesn't make the old ones terrible, just inappropriate given the boiler plate code you have to write given there are languages out there which can deliver better and more expressive solutions.

'The next big programming language' can be an interesting read.

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

Use the 'id' of the element to do the same.

var s = document.getElementById('results').style;
var b = document.getElementById('buttonId');
if(!s || !b)
   return;
b.onclick = function() {
   s.display = 'none';
};
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> However there's this one page that I changed with fontWeight that doesn't work.
Doesn't work is not a nice way to describe your problem. What exactly happens? Are there any javascript errors? Try opening the same page in Firefox and see if there is anything informative in the error console.

> anchor[i].getAttribute('name') IE doesn't like getAttribute() . Directly access the properties instead like anchor[i].name

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

Yes, Moderators, Super Moderators, Admins and Donators can have custom titles.

PS: And oh Dani, how is it that you have a rep power of 31 by having 4 dots and I have 21 inspite of having 6 dots?

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

You people are getting confused between newline and carriage returns. A carriage return is just a carriage return and is always '\r'.

It's the 'newline' character which is different on different systems. (\r, \n, \r\n)

~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

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

> I'm a programming newbie starting to study VB and, like many others, I wonder if this
> is the best language to learn.
Absolutely no. There are better languages out there like Java, Python etc.

> then I could judge the capabilities of each and decide which is right for me
You don't decide the merits of a programming language based on whether it generates and executable or not!!

> I think it would be educational to study the source code of other programs.
As far as learning from others' code is concerned, head over to sourceforge which is the home of numerous open source projects out there, just pick up your favorite programming language project and start studying / contributing.

> How can I determine the programming language of an .exe file? And how can I view it?
AFAIK, you can't, in both of the cases.

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

But in return of all this you get flexibility, the ability to change the logic without sifting through 6000 lines of your markup. Plus the load times would be less than or at the most equal to the time taken to set onclick on 6000 links by hardcoding them.

I guess this is one of those choices the OP would have to make based on his requirements.

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

Or better yet to put a piece of code in 'onload' which loops through all the links or links based on a given class and just attach a function to the 'onclick' event handler if what he needs is a common or almost common behavior for those links...

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

Like you said, since 'href' isn't an event handler I wouldn't have much faith in the first approach and I have never seen it being used in a professional environment.

The same issue occurs with the second approach since you end up calling a function inside the 'href'. A better way would be to use :

<a href="#" onclick="myFunction();">Take me away</a>

> unsure which is taking up more of my processor by dynamically creating onclick events
Profiling your application is the way to go here.

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

Ideally there should be 'zero' Java code in your JSP file. Use JSTL's instead which help in separating the business and presentation to a greater extent. A brief tutorial here.

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

I hope you don't say the same thing to your customers...

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

^
A sensible young man.

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

Damn it, my spellchecker has got disabled again. I don't know why but any changes made to anything related to Javascript messes up with the spellchecker big time.

I guess the three options being merged into one is the cause of this.

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

Your code is far from being a proper XHTML document, but works in IE, since its really forgiving. A few things:

  • All the form elements should go in the form tag. Its only when they go inside the form tag, a name attribute given to them is valid, otherwise name attribute for non-form elements is deprecated.
  • The language attribute of <script> tag is deprecated. Use 'type ' instead. Something like <script type="text/javascript">.
  • Its always recommended to place your script in the header section or include it at the bottom of your page.
  • The way you are accessing the elements is completely wrong. One possible way would be to just pass the form element to the validate function and let the function pull out values from the form. Something like this: <input type="submit" value="Push" onclick="validate(this.form);" />

I would recommend you to get hold of a good tutorial (google is your friend) and start some serious reading.

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

> And what exactly is Alice?
"Alice ML is a functional programming language based on Standard ML, extended with rich support for concurrent, distributed, and constraint programming."

~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

> 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

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

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

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

> 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

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...