~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

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

You need to toggle the rendering and not visibility. Even invisible elements takes up space on the page. Use the "display" property to create invisible elements that do not take up space.

<div id="testDiv" style="display: none;">Content</div>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Use MySQL Connector J, a type 4 / pure JDBC compliant driver. Make sure you add this driver to your runtime dependency and you are good to go.

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

> I have tried my level best to complete the project within 2 months but I am not able to do
> that.
Maybe you looked in the wrong places; the internet is choke full of resources which can help you complete almost every school level project. You just need to google for 'jsp tutorial' or 'jsp samples' and along those lines and you would have enough on your hands to keep you busy reading for weeks to come.

> If anyone can solve my problem of combobox then also it will be ok. request.getParameter("nameOfYourCombo"); or request.getParameterValues("nameOfYourCombo") if you are allowing multiple selection.

It is the very basic concept of Servlet / JSP programming. Read this.

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

This happens almost always due to Javascript errors and the Javascript on that page looks all messed up. Remember that IE is more forgiving and will automatically make up for your mistakes; Firefox won't. Your best bet would be to get your generated HTML validated, look for any glaring markup errors and if it still doesn't work, look at the 'Error Console' of Firefox to see if it really is your Javascript which is blowing up.

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

And replacing the onclick with onmouseover doesn't seem to work?

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

Posting the server side code is pointless since browser embedded Javascript works with / operates on the generated content. Plus with no definitions of functions like $find(), $object(), show() how do you expect us to help you out? Maybe this question would be more suited in the C# / ASP .NET forums considering considering that you are making use of custom components.

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

Initially attach a styleclass to all the links on your page which will keep them hidden using the display / visibility CSS property.

Attach an event handler to the onload event listener which would make these links visible only after the entire page has loaded, by virtue of the onload handler not being fired till the entire page is loaded, and hence your animations, unless you are employing lazy loading.

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

> When I use ajax request, the content renders alright too but didn't show up on the page
> source

This is because the data is fetched asynchronously only after the response is committed to the client. So what you see is the original response rendered by the server; it won't show you the data dynamically fetched using Ajax. Instead of bringing in the entire DIV using an Ajax request, place an empty DIV with an ID of 'news-xxx' on your page and fetch it's contents using Ajax.

As far as viewing the current state of DOM is considered, a Firefox extension DOM Inspector might be of some help.

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

Where is the definition of the empty() function? It would be better if you posted a working copy of your code which we can directly use for testing your example rather than trying to figure out what seems to be wrong in the small snippet presented to us.

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

> How can I fill the content with ajax responseText ONLY after the page structure has been fully
> loaded?

Attach a listener (function) to the onload event handler which would load all the values using Ajax requests only after the page has been loaded.

> is it matters if the file is not an html? is .html file faster to render than .php?

This question doesn't make sense. The client always gets to see HTML; PHP / Servlets / ROR etc. are just server side constructs which add dynamic nature to the pages being presented to the client. If your pages don't have any dynamic content, go with HTML otherwise with any server side language of your choice.

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

It would be better if you posted the code as it is rather than posting it in bits and pieces. Here is a small working example which is almost like yours and is working fine:

<!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 addUp() {
      var divElem = document.getElementById("myDiv");
      var liElem = divElem.getElementsByTagName("li")[0];
      var ipElem = liElem.getElementsByTagName("input")[0];
      alert(ipElem.value);
    }
    </script>
</head>
<body>
  <form id="frm" name="frm" action="#">
    <div id="myDiv">
      <li>
        <input type="hidden" value="10">
      </li>
      <li>
        <input type="hidden" value="20">
      </li>
      <li>
        <input type="hidden" value="30">
      </li>
      <li>
        <input type="hidden" value="40">
      </li>
    </div>
    <br><br>
    <input type="button" value="Calculate" onclick="addUp();">
  </form>
</body>
</html>

It would be much more reasonable to just grab hold of the DIV element and then get all the INPUT elements or directly get all the INPUT elements instead of adopting the round about way of grabbing hold of LI'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">
    <meta http-equiv="Expires" content="0"> <!-- disable caching -->
    <title>Example</title>
    <script type="text/javascript">
    function addUp() {
      var total = 0;
      var divElem = document.getElementById("myDiv");
      if(!divElem)
        return;
      var elems = divElem.getElementsByTagName("INPUT");
      if(!elems)
        return;
      for(var i = 0, max = elems.length; i < max; ++i) {
        var e = elems[i];
        if(!e)
          continue;
        var val = Number(e.value);
        if(!isNaN(val))
          total += val;
      }
      alert("Total: " + total);
    }
    </script>
</head>
<body>
  <form id="frm" name="frm" action="#">
    <div id="myDiv">
      <li>
        <input …
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You are welcome. :-)

BTW, if your question is answered, please mark the thread as solved by clicking on the link 'Mark As Solved' so that it becomes easy for others who use the search feature of this forum to find solution to their problems.

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

You are doing a getElementById() for "I1" but there is no element which goes by the ID "I1"; you only have an IFRAME with a name attribute of "I1". IE is infamous for allowing such things to slip by. If a call to getElementById() returns null , it looks for an element with the same name and if found; uses that. I am pretty sure your code would have failed even in Opera or any decent browser out there.

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

An oversimplified example would be:

Parent.html

<!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>Parent</title>
    <script type="text/javascript">
    targetElement = null;
    function makeSelection(frm, id) {
      if(!frm || !id)
        return;
      targetElement = frm.elements[id];
      var handle = window.open('Child.html');
    }
    </script>
</head>
<body>
  <form id="frm" name="frm" action="#">
    <span>Name: </span><input name="txtName" id="txtName">
    <input type="button" value="Select Name" onclick="makeSelection(this.form, 'txtName');">
  </form>
</body>
</html>
Child.html

<!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 makeSelection(frm, id) {
      if(!frm || !id)
        return;
      var elem = frm.elements[id];
      if(!elem)
        return;
      var val = elem.options[elem.selectedIndex].value;
      opener.targetElement.value = val;
      this.close();
    }
    </script>
</head>
<body>
  <form id="frm" name="frm" action="#">
    <span>Names: </span>
    <select name="nameSelection">
      <option value="holly">Holly</option>
      <option value="golly">Golly</option>
      <option value="molly">Molly</option>
    </select>
    <input type="button" value="Select Name" onclick="makeSelection(this.form, 'nameSelection');">
  </form>
</body>
</html>

The code in itself is self explanatory but feel free to ask for explanations.

FireNet commented: Thanks for the javascript code, works for my needs +5
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Or a better way would be to encapsulate all the functions which need to be executed inside a single function and call that function instead. <body onload="doAll();">...</body> > It seems that one disables the other and only one is working when previewed together.

We would have no way of knowing what the problem is unless you post some code or provide some more explanation.

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

My post was not meant to open up a whole new can of worms regarding the font size and the column limit currently used; the only point I wanted to make was that one of the way to do away with the frustrating experience when posting code was to use spaces instead of tabs and follow the ?? column limit Daniweb has.

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

Just follow the golden rule of never using TABS in your source code along with following the 70/80 column limit by using good source code formatters and you should be good to go without having to rely on which algorithm is used to format/render your code.

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

> Usage: java FriendClient <host> <friend_port>

This means that the program expects two command line parameters; the host name / address of the person you want to chat with along with the port to which chat application will listen to on his computer.

Like it has been already mentioned rightly, you need to read some good beginner books before diving in a complicated topic like Socket programming.

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

Considering that you are ready to learn, you need to look at some good tutorials posted at Suns' J2EE site which has everything you need to know about JSP's and much more. They also have a sample application which will serve as a good reference. A good book like Head First Servlet's and JSP's should make you more than an expert on the topic though and is a must read once you grasp the basics.

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

Like it has been already mentioned, use JSP's only for presenting data and not running your database code or parsing a JSON string; use servlets instead. And as far as parsing JSON using Java is concerned, there are a lot of JSON/Java bindings out there.

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

There is no way you can access a Javascript variable set on a page on other pages. Just pass around the JSON object to the server and persist it in the client session if you need it across pages / requests. You can even process the JSON object at the server using the server side language of your choice.

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

Maybe the code before the edit and after the edit are no longer same? People tend to make such mistakes and in almost all cases, it turns out to be a silly one. Use the Error Console feature of Firefox to nail the problem.

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

Relying on Javascript to deliver the business functionality is dangerous to the business which you are trying to cater. If this is some school project, it doesn't matter anyways but if this is for real, you need to start rethinking your design and add a server side check for such critical functionality.

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

> Can i use Language like PHP ? or what ever you think that easy to learn ?

There are many languages out there like Java, Perl, PHP etc. Pick any one of them and start learning though PHP seems to be the easier choice here because of its widespread use.

> I am not sure what kind of change would be unless change like example :
> In the file2 change a background because file3 got click on his page .
> example :
> Change file3 his one element ID , because file2 and his pal file1 got name from the user .

You can do all that and much more once you start off with server side programming. These server side technologies impart dynamic nature to the otherwise static pages and so changing the background color of a page based on a click on another page and much more complicated things are possible.

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

Develop using Firefox. You can use a nifty feature of Firefox called the Error Console which shows you all the Javascript errors on your page (if you have any).

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

> FIRST : Can I call ID from the other files who contain J.S. code with ID ?

As long as the page which includes the script has an element with the given ID and the function using that ID is called after the entire page has been loaded.

> SECOND : I have Index.html , prototype-1.6.0.2.js , and I want to make changes from
> files2.html to files3.html

Questions related to external libraries are better off in their respective forums (i.e. the prototype forum), though I am pretty sure you need a server side language of your choice depending on the kind of 'change' you need.

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

This question would be more appropriate in the CSS/HTML forum. Moved.

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

> How much do you spend a time on sleep ?

If time permits me, almost around 13 hours a day.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
  • Looking after my family
  • Anime
  • Sleeping
  • Staring at the sky/ceiling
  • Punching holes in happiness
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> I think we need more focus on the content and less on silly rating and ranking systems for
> the members who post it.

Believe it or not, there are people out there who actually feel like helping others if they get something in return; and things like post ratings, reputations, best answer etc. actually makes them happy. Think of it as a motivator for the majority out there. :-)

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

> what require if someone want to be a team colleague, featured poster,moderator, etc ??

Don't think a lot about it. If you are good enough, these things will anyways come to you sooner or later. Just keep helping out people and above all, have fun. :-)

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

The deleteRow(index) approach used here is much better than the ad hoc removeChild() approach IMO.

Here is my stab at it (untested)

<!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 deleteRows(id, toDeleteHeader) {
      var obj = document.getElementById(id);
      if(!obj && !obj.rows)
        return;
      if(typeof toDeleteHeader == 'undefined')
        toDeleteHeader = false;
      var limit = !!toDeleteHeader ? 0 : 1;
      var rows = obj.rows; 
      if(limit > rows.length)
        return;
      for(; rows.length > limit; ) {
        obj.deleteRow(limit);
      }
    }
    </script>
</head>
<body>
  <table id="tbl" name="tbl" border="1">
  <thead>
    <tr>
      <td>No.</td>
      <td>Content</td>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>1</td>
      <td>Something</td>
    </tr>
    <tr>
      <td>1</td>
      <td>Something</td>
    </tr>
    <tr>
      <td>1</td>
      <td>Something</td>
    </tr>
    <tr>
      <td>1</td>
      <td>Something</td>
    </tr>
  </tbody>
  </table>
  <br><br>
  <a href="#" onclick="deleteRows('tbl', false);">Delete rows</a>
</body>
</html>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Since you need to set the bean in the session scope, you need to do something like session.setAttribute("YourBeanName", yourBeanReference); . Read the form values in a normal manner; the same way you would do for a normal form submission i.e. request.getParameter("formFieldName");

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

Yes, submit the form to a servlet, perform the processing and redirect to a page whose output you would like to have in responseText attribute of the XMLHttpRequest object.

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

Something one can wear on his hand and use it to rip out someones' intestines.

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

Where have you declared 'slopetop', 'slopebottom' and 'slopefinal'? And document.write() is evaluated as the page is being rendered. Plus Javascript is a client side technology; as soon as a page is submitted, what you get is a new page and the state maintained in Javascript variables is reset.

You need to dynamically update the value of a span or div element to get this code working as expected. Something like:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
            "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <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 calculate(frm) {
      if(!frm)
        return(false);
      var elems = frm.elements;
      var x1 = parseInt(elems['inpx1'].value, 10);
      var x2 = parseInt(elems['inpx2'].value, 10);
      var y1 = parseInt(elems['inpy1'].value, 10);
      var y2 = parseInt(elems['inpy2'].value, 10);
      var e = elems['result1'];
      alert("(" + x1 + "," + y1 + ")" + " and (" + x2 + "," + y2 + ")");
      var distance = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
      e.value = isNaN(distance) ? 'Invalid input' : distance;
    }
    </script>
</head>
<body>
  <form action="#">
    <div>(<input type="text" name="inpx1" size="5">,<input type="text" name="inpy1" size="5">)</div>
    <br>
    <div>(<input type="text" name="inpx2" size="5">,<input type="text" name="inpy2" size="5">)</div>
    <br>
    <input type="button" onclick="return calculate(this.form);" value="Calculate!">
    <br><br>
    <div>Distance: <input name="result1" readonly="readonly"></div>
  </form>
</body>
</html>
3265002918 commented: I suck a javascript (presently). Thanks. +3
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Have a look at the Javaworld article 'Solving the logout problem elegantly' to get a fair idea of how to go about doing things.

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

Of course, I don't know about others but at least my browser has some etiquette. ;-)

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

Use the Apache commons upload library to ease the task of image uploading. Once you get hold of the image, store it in the database as a BLOB (Binary Large Object). and retrieve it back as a stream of bytes which can be used for recreating the image. Maybe this article will get things moving for you.

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

AFAIK, a session object is automatically created as soon as a request to a resource is made. In the Servlet API, you can get hold of the session object using request.getSession(), which grabs hold of the session for the current request. The way the session is maintained i.e. either by using cookies of session identifiers is generally not a concern for the developer though the latter is a much better solution. This might prove to be a good read.

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

You will have to cast it to the reference type you are expecting it to return. This is because the specifications say that getAttribute() returns a variable of type Object which of course makes sense since it enables us to store a reference variable of any kind. Maybe something along the lines of:

session.setAttribute("isLoggedIn", Boolean.TRUE);
Boolean b = (Boolean)session.getAttribute("isLoggedIn");
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

This is because you have specified a relative URL and with you currently in the "shipper" context, it's trying to find "UploadUnconfirmedSOServlet" in that context. What you can do here is either make use of absolute URL's or adjust your relative URL to suit your needs. Something like:

<form name='uploadSO' method='post' action='../UploadUnConfirmedSOServlet'>
<!-- making use of relative URL -->
</form>

<form name='uploadSO' method='post' action='/myapp/UploadUnConfirmedSOServlet'>
<!-- making use of absolute URL -->
</form>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The == operator in case of references compares the references and not the values to which they refer. Since both id and key don't refer to the same string instance in memory, it always returns false. What you need here is to use the equals() method to do the same.

But seriously, this is the very basic of Java programming every programmer out there ought to know. I would recommend you go through the basic Java programming tutorials on the official Sun site before diving head first in J2EE.

oldestprofessional commented: Thanks! Your post helped me solve my silly mistakes too... +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Happy to help. :-)

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

Glad I could point you in the right direction. :-)

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

You need to escape the XML strings returned and convert the <, > and other characters which have special meaning in HTML to their HTML entities.

< - &lt;
> - &gt;
" - &quot;

You can try something like:

String str = ab.result();
str = str.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Asking your question in the official YUI forum/newsgroup would be more beneficial IMO since almost everyone here uses his/her choice of Javascript library.

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

Looks good except for the thing that you don't explicitly set the length of the string since it's a read only property and would have no effect. Instead set the value of the form element to an empty string. Something like els[i].value = '';

OmniX commented: Helped me continualy to get a solution, Thankyou. +1