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

A typo there:

if (expandable.style.display = 'none') {

should be:

if (expandable.style.display == 'none') {
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You can loop over all the form elements using the elements attribute of the form or get all the elements under the div and do a selective filtering.

<!--
Author: ~s.o.s~
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
            "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv"Script-Content-Type" content="text/javascript">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Example</title>
    <script type="text/javascript">
    function showOfForm(frm) {
      if(!frm || !frm.elements) {
        return;
      }
      var elms = frm.elements;
      for(var i = 0, maxI = elms.length; i < maxI; ++i) {
        var elm = elms[i];
        alert("Type: " + elm.type + "\nName: " +
                elm.name + "\nId: " + elm.id);
      }
    }
    function showOfDiv(div) {
      if(!div) {
        return;
      }
      div = typeof div === "string" ? document.getElementById(div) : div;
      var elms = div.getElementsByTagName("*");
      for(var i = 0, maxI = elms.length; i < maxI; ++i) {
        var elm = elms[i];
        switch(elm.type) {
          case "text":
          case "textarea":
          case "button":
          case "reset":
          case "submit":
          case "file":
          case "hidden":
          case "password":
          case "image":
          case "radio":
          case "checkbox":
          case "select-one":
          case "select-multiple":
            alert("Type: " + elm.type + "\nName: " +
                    elm.name + "\nId: " + elm.id);
        }
      }
    }
    </script>
</head>
<body>
  <form id="frm" name="frm" action="#">
    <div id="divOne" style="border: thick solid yellow">
      <input type="text" name="txtOne" id="txtOne"><br>
      <input type="submit" value="Click me" name="btnOne" id="btnOne"><br>
      <input type="radio" name="radGrp1" id="radOne"><br>
      <input type="radio" name="radGrp1" id="radTwo"><br>
    </div>
    <br><br>
    <div id="divTwo" style="border: thick solid red">
      <select name="selOne" id="selOne" multiple="multiple">
        <option value="one">1</option>
        <option value="two">2</option>
        <option value="three">3</option>
      </select>
      <br>
      <input type="checkbox" id="chkOne" name="chkGrp1"><br>
      <input type="checkbox" id="chkTwo" name="chkGrp1"><br>
    </div>
    <br><br>
    <input type="button" onclick="showOfForm(this.form);"
      value="Show form elements" name="btnTwo" id="btnTwo"> …
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The error message "Cannot make a static reference to the non-static method" says it all. You need to first instantiate the XYChartExample2 class before invoking its method. BTW, scriptlets are bad and knowing the basics of Java helps before jumping into J2EE.

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

> As far as the programmer making a mess of the programming, that can always happen.

Though the probability increases in this case. :-)

> And, I never said he should call thread destroy, or anything in that manner.

I guess I misread your first post.

The stop button will call another jsp that will retreive the object stored under that key and call the "stop" method.

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

IMO creating and manipulating threads in a managed environment is bad in itself since the request is already being processed by a thread and the chances of the programmer screwing up with threading and making the mess out of the entire affair is pretty high. Plus, there is no reliable way of completely stopping a thread since it's inherently unsafe and has been deprecated.

If the user isn't expecting a quick response, one possible way would be to use asynchronous messaging. A better method would be to make the entire process interactive and execute the process in chunks so that the user always has the option of going back or canceling the process under consideration.

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

Since you can manipulate the listener, something like this should be of some use to you:

package home.projects.daniweb;

import java.net.URL;
import java.net.MalformedURLException;
import java.io.InputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class URLTester {
  public static void main(String args[]) {
    String url = "http://www.google.com/";
    try {
      InputStream in = null;
      try {
        // Open a connection to the resource specified in 'url' and grab hold
        // of the stream.
        URL urlObj = new URL(url);
        in = urlObj.openStream();
        
        // Spit the response to the screen
        BufferedReader bufIn = new BufferedReader(new InputStreamReader(in));
        System.out.println("RESPONSE BEGINS\n");
        String str;
        while((str = bufIn.readLine()) != null) {
          System.out.println(str);
        }
        System.out.println("RESPONSE ENDS\n");
      } finally {
        if(in != null) {
          in.close();
        }
      }
    } catch(Exception e) {
      System.out.println("An exception has occured; " + e.getMessage());
    }
  }
}

If you are relying on a user input and if the action for that is well defined e.g. a user clicking on the logout link, you can code it as a simple HTML page:

<html>
<head>
  <script type="text/javascript">
  // Some script
  </script>
</head>
<body>
  <a href="/setPresence.cfm?user=bob&isOnline=0">Logout</a>
</body>
</html>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Though I am not sure as to what you are trying to achieve, you are getting the mentioned error because the URL constructor (the call new URL() ) throws a checked exception which you need to either catch or make the method have a throws clause.

try {
  URL url = new URL("someURL");
} catch(MalformedURLException mue) {
  // received an invalid url
}

OR

public void doSomething() throws MalformedURLException {
  URL url = new URL("someURL");
}

And BTW, scriptlets are a strict no-no for a variety of reasons. Plus, it would be kind of difficult for you to get into J2EE if your basic Java concepts aren't clear enough.

Nick Evan commented: Good post. (and congrats on you 7th dot;) ) +6
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

cover[0] is not a valid name. There are a fixed set of rules which govern what exactly a valid name looks like. Keep it something like cover0 .

When developing, use Firefox so that tracing such errors is a breeze using the Firefox Error Console and Firebug plugin. You would get a much detailed error in contrast to the almost useless 'Object expected' stuff thrown in by IE.

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

The only way to exclude fields from being passed with the querystring is to mark them as disabled. Disabled form data is not submitted. How to achieve this would be your call.

You can on form submit call a function which would disable all the fields whose trimmed value is a blank string.

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

The best place for these types of questions would be the Peoplesoft support forum where many others might have faced the same problem.

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

Server side code has no place in the Javascript code, you should take a look at the generated code to pinpoint your problem. Use tools like the Error Console of Firefox and Firebug to debug your code.

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

How about posting the code which doesn't work and asking specific questions? That way it would be easier for the others to pinpoint the problem you are facing.

If you are talking about dynamically creating form elements, Google for createElement and appendChild .

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

Yes we would, take a look at the documentation of the String object of Javascript; you would find all that you require to complete your task.

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

You need to use the 'selected' attribute of the OPTION element based on the value fetched from the database.

<selected name="selBox">
  <option value="cityOne">City One</option>
  <option value="cityTwo" selected="selected">City Two</option>
  <option value="cityThree">City Three</option>
</option>

In the above snippet, "cityTwo" would be the value fetched from the database.

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

If the only problem you are facing is grabbing hold of the mouse coordinates, try the Event properties article at quirksmode.

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

> should the code for cookie be written in a separate cookie file or should it be written in
> one of the two files that pass and receive data.

The code for cookie management would come in both the HTML documents; in the first one for writing to the cookie and in the second one for reading from the cookie.

> what if i hand over my files to a friends who absolutely has no idea about html but he just
> uses the files to quickly check out some data. If the cookie is deleted, he will do nothing
> but curse me

The cookie creation code would take care of writing the value to the cookie every time the first page is run.

> How will the data be received in the target file ? can it be stored in some variable in a
> target file ?

If by the target file you mean the second HTML document, then yes, you would call a function when the body loads which would read the required data from the cookie written by the first HTML document.

<!-- second html file -->
<html>
<head>
  <script type="text/javascript">
  function readCookie() {
    var valueReadFromCookie = ... // read data from cookie
    var frm = document.forms["frm"];
    var txtBox = frm.elements["txt"];
    txt.value = valueReadFromCookie;
  }
  </script>
</head>
<body onload="readCookie();">
  <form id="frm" name="frm" action="#">
    <span>Value read: </span>
    <input name="txt" id="txt">
  </form>
</body>
</html>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Javascript is amazing, I didn't think you could touch mysql with it!

You can't, at least not with browser embedded Javascript. It's a different ball game altogether if you are using Server Side Javascript.

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

Don't use scriptlets, use something along the lines of JSTL or JSF. Don't use normal statements, use prepared / callable statements. Read the official Sun J2EE developer guide for J2EE best practices.

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

Since the original request has been solved, create a new thread for questions unrelated to it.

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

> I searched, but can not find the one I want.

A simple google query turns up a lot of interesting results. You can't be choosy when it comes to something which is given for *free*, so your argument of 'not finding the one you want' is kind of moot.

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

You need to first provide us an effort on your part before we can help you with your problem. Attempt it, tell us where you are getting stuck and you might just get lucky.

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

You would need to use cookies for this purpose. When the drop down on your page is selected, you can set the required value in the cookie, navigate to that page and read the value from that cookie when the second page loads to populate the text box.

For more information / code snippets on cookies, visit http://www.quirksmode.org/js/cookies.html

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

If this poll is for registered users only, a better way would be to handle the voting part at the server side wherein an entry would be placed in the database against the users' name and be checked for each vote request so that he can vote only once.

If this poll is for all users of your site, cookies seem to be your best bet; though beware that if cookies / javascript are disabled, it can cause serious statistical issues. One way to avoid this would be to make the 'Post a Poll' button Javascript enabled and do a check whether cookies are enabled which disables the post a poll option for users who have javascript / cookies turned off.

BTW, all you need to know about browser cookies.

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

A simple script like this should do the job. Do keep it mind that it can be made better in a lot of ways but for your purpose it should serve well enough:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
            "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv"Script-Content-Type" content="text/javascript">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="Expires" content="0"> <!-- disable caching -->
    <title>Example</title>
    <script type="text/javascript">
    function handleAutoAppend(e) {
      // A mapping which maintains a list of what needs to be appended for
      // which key pressed by the user.
      var mappings = {k : "000", m: "000000"};
      
      // Process the event triggered by the user and grab hold of the element
      // on which it was triggered along with the pressed keys' value
      e = e || window.event;
      var code = e.which || e.keyCode;
      var key = String.fromCharCode(code);
      var elem = e.srcElement || e.target;
      
      // For each 'value' of our interest, append the requisite string at the 
      // end of the existing text and return(false) so as not the render 'k'
      // or 'm'
      for(var k in mappings) {
        if(key == k) {
          var val = mappings[k];
          if(elem) {
            elem.value = elem.value + val;
            return(false);
          }
        }
      }
      
      // For all other keys, don't do anything; allow the default behavior 
      // to take over.
      return(true);
    }
    </script>
</head>
<body>
  <form id="frm" name="frm" action="#">
    <p>Enter something:</p>
    <input type="text" name="txt" id="txt" onkeypress="return handleAutoAppend(event);">
  </form>
</body>
</html>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Post the *relevant* code which is not working; it's probably one of those browser incompatibility issue you are facing there which is very much solvable.

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

You need to post the relevant piece of code for us to help you out; debugging script which we can't see is kind of difficult. :-)

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

A tough question, it's like deciding which of your kids you like the most. ;-)

A few I can think of right now:
• Canvas II
• Shakugan no Shana
• FLCL

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

It's not that you compulsorily need Winzip to open .zip files; they can be opened or processed using free softwares like 7zip.

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

> how to make div id's as unique (since it need to identify a unique div for each row)

One way would be to create a separate counter (e.g. i) which would be incremented for each "for each" block and create an ID dynamically by appending the common name with this counter value. Something like: <div id="<%= puts 'someDiv' + i %>"> (an approximation since I don't know ruby)

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

> I was so disappointed to read your reply, I thought somebody could illuminate the quirks
> of prototype.js/window.js

I am pretty sure that the quirks of prototype.js can be better explained by the people *at* prototype.js message board; this board is more focussed on general Javascript discussion.

> To me, your example is unnecessarily verbose,

I keep my examples extremely verbose and simple so that beginners don't have a problem understanding them and I had no way of knowing that you had experience with Javascript. I could have added loads of checks but at the cost of confusing the newbies. I am also missing a DOCTYPE but that's a different story altogether...

> In the prototype.js environment you can write document.getElementById('idvalue') as
> $('idvalue') so I'm sure you can understand the simplicity/productivity increase inherent in
> using the libraries.

And what about the people who has just started Javascript? I very well understand the productivity increase / decrease when using Libraries but don't want to drag it all here when there are people people out there struggling with the basics of Javascript.

> you should use ids to shorten the DOM path of elements

I disagree; I would rather pick up ready made references from the 'elements' HTMLCollection than traverse the DOM for a trivial task like getting a reference to a form element...

> I have been writing JavaScript …

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

Damn, not being visibly active really sucks. ;-)

majestic0110 commented: lol - I've seen you do some great moderation too my friend! +3
peter_budo commented: You do a great job and I'm happy to share Web Development section with you +8
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Is there a particular name for this type of comment box?

Yes, it's called a WYSIWYG (What-you-see-is-what-you-get) editor. Here is one which you can use for your site.

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

> I am new to java coding.I m struggling to make a below project. Can u plz. help on this
> project.

Grab hold of a copy of "Sun's J2EE 1.4 (1.5) Tutorial" freely available online which hosts some sample projects along with a well detailed implementation.

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

Why not just create a normal window? The child window holds a reference to the parent window which created it in the form of 'opener' property. Here 'opener' is the window object of the parent window.

Parent.html

<html>
<head>
	<script>
	function go() {	
		window.open("Child.html");
	}
	</script>
</head>
<body>
<form name="frm">	
	<input type="text" value="Hello" id="txt" name="txt" />
	<input type="button" name="btn" id="btn" value="Button" onclick="go();" />
</form>
</body>
</html>
Child.html

<html>
<head>
	<script>
	function go() {
		alert(opener.document.forms[0].elements["txt"].value);
	}
	function change() {
		opener.document.forms[0].elements["txt"].value = "This is changed text";
    opener.focus();
		this.close();		
	}
	</script>
</head>
<body onload="go();">
	<form>
		<input type="button" value="Change Value in Parent" id="btn" name="btn" onclick="change();"/>
	</form>
</body>
</html>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> I have javascript and ALL of it works in IE but in FF NONE of it works at all.

You are in luck; just take a sneak peak at the Error Console of Firefox (Tools -> Error Console) for any Javascript related errors. Also if you are into extensive Javascript programming, grabbing hold of Firebug (a firefox extension specifically tailored for Javascript debugging) would do you a lot of good.

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

The problem statement in itself is kind of confusing; it would be better if you posted a small relevant piece of code which would demonstrate the problem so that others can try to help you out. Also if you are allowed to, you can take help of some external utility libraries out there to do away with the problem of manually handing browser inconsistencies when programming in Javascript.

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

> i want to develop a code such that when i click on the text next to the radio button the radio
> button should be selected and even if the button is clicked
You don't need Javascript for this; use the HTML label tag.

<p>Try clicking on the text labels:</p>
<form name="input" action="">
<input type="radio" name="sex" id="male" />
<label for="male">Male</label>
<br />
<input type="radio" name="sex" id="female" />
<label for="female">Female</label>
</form>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

This thread has got nothing to do with Javascript; it would be more relevant in the CSS section. Moved.

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

This code snippet would be more suited in the Code Snippets section where it can be used / referenced by the masses out there. Please reconsider posting it there.

A few comments:
location is a property of the window object and not the document object.
• Using document.write() is not so graceful; disable javascript and watch your page fail miserably. A better and more appropriate way would be to use DOM manipulation.
• It would be better if the slider could be configured by passing parameters to the function call i.e. Dr_ImgArr(stepTime, padding) • It would be even better if you could wrap the entire functionality inside a custom object which the user can instantiate. This object would have state and do away with the requirement of having globally scoped variables.

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

This thread is going off-topic is a big way. Thank you all for participating in this discussion; for more *god* related things, please feel free to start a new thread.

John A commented: It's about time. Though I disagree with the "starting a new thread" part. :P +15
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
<script type="text/javascript">
document.getElementsByName('rand')[0].value = document.getElementsByName('main')[0].src;
</script>

The function getElementsByName returns a nodelist i.e. an array of all the elements which go by that name. Hence the array indexing operator [] is a must. If you are pretty sure that there is only one element on the entire page which goes by that name, you can do document.getElementsByName('name')[0] . The first line probably sets the value of some form element e.g. an input element and the second line probably sets the source of the iframe element which goes by the name of 'main' .

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

If you want to share something good with the others out there, we have a code snippets section. Threads posted in normal forums end up getting lost in the sands of time. ;-)

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

The error "MyRemote cannot be resolved to a type." seems to be pretty straightforward; you need to include the 'MyRemote' class in your JSP for it to successfully compile. I know this advice would fall on deaf ears but avoid using scriptlets in your JSP's, put the application logic in servlets instead.

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

> You could just use a meta command (like this):

The W3C actually recommends against the use of such tricks for redirection. If Javascript is not a must, Digital Ether's suggestion seems good enough.

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

> If I have a variable named X , and this virable hold some data , how can I know
> the Type for that data

The typeof operator should make things a bit easier for you. Try this:

<script type="text/javascript">
var i = 0;
alert(typeof i);  // number
i = "0";
alert(typeof i);  // string
i = true;
alert(typeof i);  // boolean
i = [1, 3];
alert(typeof i);  // object
</script>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Place the block of Javascript code *after* the DIV tag and things should work out fine. It problems still persist, consider attaching a listener to the onload event handler of the window object which would execute the required Javascript only after the entire page has loaded.

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

Your issue has got nothing to do with Javascript; it is handled when deploying your web application on the web server / container of your choice by means of a configuration file. Consult your web server's documentation for more details.

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

There is no navigate function for the window object. Maybe try something like:

<?php
function reDirect($page)
{
     $s = "<script language = 'javascript'>
     window.location.href = '$page';
     </script>";
     return $s;
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

There are at least millions of threads out there providing a proper solution to the same problem; maybe doing a bit of research on your own would help you understand the way things work.

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

> but I dont know why JSP gives this result :

Maybe because "KodeAlbum" actually contains "000002-0015"? It would be better if you printed out the value of the form field "KodeAlbum" after form submission and made sure it is the same as you want. If yes, then the change is happening somewhere in between the request attribute being set and it's use.