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

I doubt the above code would even work in FF2 considering that you explicitly need to pass the event when registering the handler.

<a href="#" onclick="doSomething(event);">
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Above code is working fine on FF but on IE7 name attribute is not set at all.

Just because the 'NAME' attribute is not shown in the alert doesn't mean that it is not set. Try to submit the form and take a look at the submitted query string i.e. the URL, it still submits the newly created form fields. Likewise the code works perfectly fine on the recent version of Opera.

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

I need to change the names to

hobby[0], hobby[1], hobby[2], hobby[3] ...

so that I can pass POST the values to a PHP script...

Maybe something along the lines of the following snippet. Rigorous error checking omitted for brevity.

<!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">
    /**
     *  Dynamically create form elements with incremental names.
     *
     *  @param tableId The ID of the table element.
     *  @param elemName The name of the element to be dynamically created.
     */
    function addRow(tableId, elemName) {
      if(!tableId || !elemName) return;
      
      // Grab hold of a reference to the table element and return from the 
      // function if no table element exists for the given table id.
      var tblElem = document.getElementById(tableId);
      if(!tblElem)  return;
      
      // Insert a new row at the end of the table, a new cell at the start
      // of that row and a new text node to the newly created cell.
      var newRow = tblElem.insertRow(-1);
      var newCell = newRow.insertCell(0);
      var txtElem = document.createElement("INPUT");
      txtElem.name = elemName + "[" + (tblElem.rows.length - 1) + "]";
      newCell.appendChild(txtElem);
      
      alert(document.getElementsByTagName("BODY")[0].innerHTML);
    }
    </script>
</head>
<body>
  <form id="frm" name="frm" action="#">
    <table id="tbl">
    <tbody>
      <tr id="dolly">
        <td><input name="hobby[0]"></td>
      </tr>
    </tbody>
    </table>
    <div>
      <input type="button" value="Append" onclick="addRow('tbl', 'hobby');">
      <br>
      <input type="submit">
    </div>
  </form>
</body>
</html>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> is not standard function avoid to use this.

On the contrary, it is.

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

Just because it works doesn't mean it is correct and will surely always work. IE has a peculiar habit of working with NAME when it doesn't find an element with a given ID. So document.getELementById('someId') will first look for an element with an ID of ' someId ' and failing to find so will look for an element having NAME ' someId '. That's why it *works* in IE in your case. It it worked with NAME , don't you wonder why they kept the name of the function as getElementById ?

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

Look into HTML DOM classes Table, TableCell and TableRow.

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

Firefox comes with an excellent debugging utility called Firebug which you can put to your use in this case. Also, the problem might lie in the code which changes the INPUT element to SELECT . How are you making the switch? Are you removing the old element and adding a new one or modifying the existing element? A better way here would be to inspect the state of the web page after show_select() function has been called.

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

You *always* need to use ID 's instead of NAME 'S when using document.getElementById .

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

Certainly, a regular expression can be very well used for filtering out elements based on the pattern which can then be used to do additional processing.

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

Maybe something like this snippet will help you getting started. Ensure that the elements you are trying to access are form fields enclosed in the form tag.

<!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">
    /**
     * A placeholder function which will be called on the button click which
     * in turn invokes the function which contains the core logic.
     *
     * @param frm The reference to the form element
     * @param pattern THe pattern to be used for matching.
     */
    function calculateForPattern(frm, pattern) {
      var sum = calculate(frm, pattern);
      alert("The sum of all elements whose names start with *" +
        pattern + "* is " + sum);      
    }
    
    /**
     * Calculate the sum of values of the text fields on the 
     * document whose name start with "qty"
     *
     * @param frm The reference to the form element
     * @param pattern THe pattern to be used for matching.
     * @returns The sum of the values of all the form fields
     *  whose name match the given pattern.
     */
    function calculate(frm, pattern) {
      // Duck out if no proper form reference / pattern supplied.
      if(!frm || !pattern) {
        return(0);
      }
      // Assumption: Only text fields have names starting with the given
      // pattern. For other form fields (drop downs, radio buttons) add
      // the required handling.
      var elems = frm.elements, sum = 0;
      for(var i = 0, maxI = elems.length; i < maxI; ++i) {
        var …
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Firefox comes with a pre-packaged feature called Error Console (Tools -> Error Console) which highlights all the Javascript errors on your web page. You can also grab hold of Firebug, an advanced Javascript debugging utility which is a Firefox plugin.

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

> Error: document.getElementById(treeid) has no properties

It simply means that no such object with the ID as 'treeid' (or if 'treeid' is a variable, then the value 'treeid' holds) exists in the document tree.

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

> This would probably make your life a bit easier.

And learning Java a bit tougher...

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

> Can anyone help?

Yes, only if you first post your attempt. If you are new to Javascript, start by googling Javascript tutorials and then giving it a try.

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

Put in simple terms, both are comparison operators of Javascript with the difference being that === is a type safe / type aware operator. If two operands are of the same type and same value, only then the === returns true. Whereas, in case of == if the two operands are not of the same type, they try to coerce the values.

1 == '1'  //  true
1 === '1' // false

Its always better to use === and !== whenever possible to avoid surprises.

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

Look into window.open and window.onload for achieving your objective.

mcx76 commented: thanks for help +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You seem to be thoroughly confused there. Firstly, HTML is a markup language and used as a presentation layer technology. You don't connect to databases using HTML; you need a general purpose programming language like C/C++/Java/Ruby/Python to connect to databases. Google for 'HTML Tutorial' and start reading...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
jmasta commented: Solved it! +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> If possible, just some information about the site above would be greatly appreciated.

Finding out what happens behind the scenes is kind of difficult. In your case if quality is of prime importance, generating PDF's out of images is out of the picture. Another option as I mentioned in my previous post is to look for some reporting tool which accepts Autocad files and converts it into native format. But this is more work than it is worth considering that the number of combinations is well known to you.

So IMO, the best option in your case would be to use the VB/Autocad environment to generate the fixed number of PDF's with the file name depending on the input / combination used.

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

> i want my email field to be validated such that a user can enter only valid email id...how
> should i do this?

This check can't be reliably done at client side considering that there are a lot of valid email formats. For e.g. mail provider A might not allow dots in your mail address but since mail provider B allows dots, you have to take into consideration both the options. The only reliable way of checking the validity of an email address is to introduce the concept of 'confirmation mail' in your sign up process.

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

Use the Java binding for JSON. Its pretty simple and after your JSON object has been constructed, all you have to do is store the representation in a String variable which can be accessed by your JSP; i.e. the normal way in which you pass data to and fro from you JSP.

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

> But when I click on Next link, I get "The requested resource (/getReleaseData) is not
> available.".

Take a look at the link which is displayed in the location bar of your web browser. Is path shown there same as that the location at which your servlet is present?

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

Also make sure you completely understand the implications of storing the contents of the entire file in a StringBuilder instance since this technique might just result in the entire file contents being loaded in memory which becomes a big issue for huge text files. Consider using a buffer which reads the files in fixed chunks so that you can make a happy compromise between the I/O and memory constraints.

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

The RegExp you have there is incorrect. The correct one would be:

/*
For Letters: [a-zA-Z] (dealing with both upper and lower case characters)
For Space: [ ]
Putting them together: [a-zA-Z ]+
Use a + instead of * since a blank string is not a valid letter nor a space.
Use ^ and $ since our string should start and end with the given pattern.
*/
var myStr = "hello";
if(/^[a-zA-Z ]+$/.test(myStr) {
  window.alert("String contains only alphabets and spaces");
} else {
  window.alert("String doesn't contain only alphabets and spaces");
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Since you are already using jQuery, adding Ajax functionality to your existing application won't be that difficult. The only requirement is that you would have to spend a little time (2 hours?) in reading the large number of tutorials out there.

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

If you are pulling data from the server on fly using Ajax, you can't use events like onload since there is as such no page refresh / loading happening here. This is the very reason why the dynamic content can't be seen in the static source. To view the modified document as and when it changes, use Firebug, a Firefox plugin for Javascript debugging.

If using Ajax, you can make use of the onreadystatechange event listener to make the required updates to the DOM tree.

//some wrapper function which returns XHR object
xhr = getXMLHttpRequestObject();
xhr.open('GET', someURL, true);
xhr.onreadystatechange = function() {
  // The response is ready
  if(xhr.readyState == 4) {
    // The request completed successfully
    if(xhr.status == 200) {
      var data = xhr.responseText;
      // do something with this data which modifies the DOM
    }
  }
};
xhr.send(null);

The conclusion here being that unless you are following the traditional request / response model for pulling in data, your onload event will be fired only once. Ajax requests don't trigger an onload .

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

There seems to be some problem with the way you are using Ajax or in general Javascript. Though I don't have the time to sift limitless lines of Javascript code, the exception which I get on Firefox is "Error: uncaught exception: Permission denied to call method XMLHttpRequest.open". Oh and BTW, the site doesn't even work on IE for me.

And if you are using jQuery, why don't you use its Ajax functionality instead of doing it all from scratch?

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

Duplicate thread, closed.

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

It entirely hinges on what exactly 'generated on fly' means. If it means that depending on each request the format / content of the report might change, then you would be in a big pinch if you statically generate files and keep them on your server. Depending on the number of users / hits, you might easily run out of space!

The important thing here is identifying the lower and upper bounds of the number of reports you can have. If by analyzing the problem domain, you feel that there is as such no upper bound, then you can't use statically generated PDF's as they won't scale to the requirements. AFAIK, PDF files normally use vector fonts so the quality would not have been an issue if it were not for the PNG files used to generate the PDF's (in the end, you are just embedding the image inside PDF). Normally for such things, a Reporting Engine is used (something like Crystal Reports) which can be hooked to a stored procedure to pull out data.

Maybe you should look out for some reporting tool which allows you to import Autocad files so that your task of automatic PDF generation can be simplified to a great extent. Then again, not much can be said without answering the questions posed above or before understanding the exact requirements.

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

> Then create a method in the class that loops the two arrays and checks one by one the
> elements.

Or just use the one provided by the standard library for the Arrays class. If comparing two Object arrays, use the Arrays.deepEquals(Object[] a1, Object[] a2) . When comparing arrays of primitives, use Arrays.equals(primitiveType[] a1, primitiveType[] a2).

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

Considering not everyone here uses Windows as their primary operating system; posting a screenshot and the relevant piece of code would help you in getting quick assistance. Also since you mention cutting off the image, it might just come out to be a CSS issue if you are applying some sort of style to the newly opened window / image.

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

That will in a large way depend on how your web page i.e. JSP is structured. The most simple way would be to set the value of the second column as per the value of the first column fields retrieved when the form is submitted as soon as the >> button is clicked. If you are using JSTL , you can use ${param.firstColumnName} to grab hold of the value of first column first row and use it to set the value of first row and second column.

If the usage of client side scripting is not a problem, this can be in a very simple way done using JavaScript.

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

Keep a hidden field which would carry the content of the variable idArticolo to the next page which can be then retrieved using the getParameter method of the HttpServletRequest object.

<!-- In your HTML -->
<form action="/someServlet" id="frm"
  <input type="hidden" name="hid" id="hid" value="default">
</form>
// In your javascript
function crea(valore,identificatore) {
  // All the other stuff goes here
  var hiddenElem = document.getElementById("hid");
  if(hiddenElem) hiddenElem.value = identificatore;
}

Just make sure that the crea() function gets called before the form is submitted. You can also assign a default value to the hidden field so that at the server you can determine whether that field was set or not.

Oh and BTW, using scriptlets is bad. There are better ways of dynamically writing out content like JSTL / JSF / some framework which ensure the separation of content / presentation / logic.

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

And how is it different from dynamically writing out JavaScript which developers have been using for times unknown? Plus Ajax is a different beast altogether dealing with shipping data to and fro *after* the entire page has been loaded in a manner which doesn't force a browser refresh.

So yeah, I have tried out both Ajax and JDOMJ (Java in my case) and think of them as different tools of my toolbox.

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

> Firefox is a lot more standards compliant than IE

Completely agree though I always end up forgiving Microsoft considering that they have given the Web Development World a pretty useful concept / thing like XMLHttpRequest object. ;-)

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

It probably has got something to do with a faulty javascript snippet dealing with Ajax. A lightweight library along the lines of 'Ajax Toolbox' might just make your pain go away. If not, take a look at the IE debuggers out there to assist you in finding the problematic piece of code.

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

The getParameter method of HttpServletRequet works on the name of form elements and not ID 's. You need something along the lines of:

[..] <input type="text" name="tname" id="tname"> [..]

Oh and BTW, don't use scriptlets; they are *bad*. There are better ways of developing a web application with J2EE. (e.g. JSTL, JSF)

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

Use the ServletContext's getRealPath() method to grab hold of the OS dependent real path of your web application's root. For e.g. on Windows system, it might look something along the lines of F:\Tomcat6\webapps\MyWebApplication] .

BTW, I am pretty sure that there are better ways of doing the thing you are trying there; just stream the generated bytes to the user by setting the appropriate response headers so that he gets the 'Save As / Open' pop up. Creating files and spawing threads and one of the few things you have to be *very* careful about in a managed environment.

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

Developing cross browser applications is a real pain. A good option is to use one of the Javascript libraries out there which handle most of the Javascript inconsistencies out there though CSS related issues would have a different story to tell.

If it's Firefox, your best bet would be to install the Firebug and Web Developer plugin and start hacking.

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

Why not just replicate/take inspiration from the logic and create one in C++? I am pretty sure the efforts put in creating one from scratch in C++ would be far less than calling a script from your C++ program though I am pretty sure that the latter is a pretty bad idea unless you are using the script for orchestration and letting your graphics engine handle all the gory stuff.

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

Dynamic in the sense of generating dynamic content on fly or a site with client side enhancements? For the former, learning a server side web development language like PHP/Python/Java would be the way to go. If it's the latter, you would have to know a great deal about Javascript or at least expertise in one of the many Javascript libraries/toolkits out there.

No matter the choice, there are loads of introductory tutorials / books out there. Decide on something and get started though the ideal choice would depend a lot on your programming background.

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

> Is javascript the way to go with this?

No, AFAIK it can't be done in Javascript irrespective of whether the PDF's are pre-generated / generated on fly. The way to do it would be process the user input at the server and set the response headers accordingly when the response is thrown out.

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

Queries related to Javascript libraries like Prototype are better asked in the specific forums (unless you already haven't asked it there!) since there might be many out there who would have faced a similar problem and hence is one of the fastest way of getting help.

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

On the surface the code looks error free though I am pretty sure that IE doesn't play well with getAttribute and setAttribute . Just replace them with this.href and this.title (or better yet, just pass this !). If you still are unable to find a solution, there are a few IE Javascript debuggers out there which you can put to good use in your case.

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

The error says it all:

Error: document.getElementById(treeid) has no properties
Source file: http://gizmoearth.com/simpletreemenu.js
Line: 10

You should start developing in Firefox and use its Error Console feature for Javascript development. Another good option would be to get hold of Firebug which allows you to do Javascript debugging!

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

That sounds kind of...creepy. ;-)

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

@mgt:

Don't create multiple threads for the same topic. It ends up wasting the time of people who reply to those threads thinking there was no reply given.

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

Here is a sample script (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">
    <title>Example</title>
    <script type="text/javascript">
    // This function sets the hidden field value to the value of the drop
    // down contents in the form of comma separated values. Read this 
    // hidden variable at teh server just like any normal form field, parse
    // it and pick out its contents.
    function setHidden(frm) {
      if(!frm) {
        return;
      }
      var selBox = frm.elements["sel"];
      var selValue = "";
      for(var i = 0, maxI = selBox.options.length; i < maxI; ++i) {
        var opt = selBox.options[i];
        if(opt.selected) {
          selValue += opt.value + ",";
        }
      }      
      var hiddenElem = frm.elements["hiddenParam"];
      hiddenElem.value = selValue;
      window.alert("The value to be submitted is: " + selValue);
      frm.submit();
    }
    </script>
</head>
<body>
  <form id="frm" name="frm" action="#">
    <select name="sel" id="sel" multiple="multiple">
      <option value="one">1</option>
      <option value="two">2</option>
      <option value="three">3</option>
      <option value="four">4</option>
    </select>
    <input type="hidden" name="hiddenParam" id="hiddenParam">
    <br><br>
    <input type="submit" onclick="setHidden(this.form);">
  </form>
</body>
</html>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Keep a hidden form element on your page which will be populated / updated whenever the user submits the form / changes the value of the secondary drop down. This hidden field can then be read using PHP at the server in the same way you read normal text fields.

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

> I feel for you dude

Dude? Bah, I blame Narue-chan for having a male avatar. ;-)