need some help to write a javascript function

Discussion in 'Javascript' started by adi, Jun 30, 2008.

  1. adi

    adi Guest

    Hello guys.

    This is Aditya. I have a jsp where i am displaying more than 10,000
    records and finally i am adding the values of these records in the end
    and displaying the total value as Total: .
    My Task:
    Now i want to write a javafunction which can shrink these 10,000
    records into a word say (Add). When the user comes and selects or
    clicks this Add then he can view all the 10,000 records and if he
    doesnot click Add, then only the total should be displayed.

    I have already wriiten the logic to display the total only. Now i am
    struck with the javascript part .

    It would be really great if anybody help me out with this problem.
    Waiting for your replies.

    Thanks in Advance.
    Aditya Reddy
    adi, Jun 30, 2008
    #1
    1. Advertising

  2. adi wrote:
    > [...] I have a jsp where i am displaying more than 10,000
    > records and finally i am adding the values of these records in the
    > end and displaying the total value as Total: .
    > My Task:
    > Now i want to write a javafunction which can shrink these 10,000
    > records into a word say (Add). When the user comes and selects or
    > clicks this Add then he can view all the 10,000 records and if he
    > doesnot click Add, then only the total should be displayed.
    >
    > I have already wriiten the logic to display the total only. Now i am
    > struck with the javascript part .


    JSP are JavaServer Pages, not JavaScript Pages. Java, unless related to
    LiveConnect/XPConnect, is off-topic here and on-topic in comp.lang.java.ALL
    instead.

    You really don't need J(ava)Script here. What exactly do you want to
    accomplish with it? Which part of J(ava)Script programming have you
    problems with?

    Please read <http://www.jibbering.com/faq/#FAQ2_3>.


    PointedEars
    --
    var bugRiddenCrashPronePieceOfJunk = (
    navigator.userAgent.indexOf('MSIE 5') != -1
    && navigator.userAgent.indexOf('Mac') != -1
    ) // Plone, register_function.js:16
    Thomas 'PointedEars' Lahn, Jun 30, 2008
    #2
    1. Advertising

  3. adi

    yukabuk Guest

    I think what shes trying to explain is have a hidden div containing
    results which then displays after the user clicks on the 'Add' link.

    Aditya, try this...

    <div id='results' style='display:none;'>
    ....
    All your html results in a table
    ....
    </div>

    <button
    onmouseup='document.getElementById("results").style.display="inline";'>Add</
    button>

    Graham
    yukabuk, Jul 1, 2008
    #3
  4. yukabuk wrote:
    > I think what shes trying to explain


    .... which you have not quoted at all, despite e.g. the FAQ recommending
    otherwise ...

    > is have a hidden div containing results which then displays after the user
    > clicks on the 'Add' link.
    >
    > Aditya, try this...
    >
    > <div id='results' style='display:none;'>
    > ...
    > All your html results in a table
    > ...
    > </div>
    >
    > <button
    > onmouseup='document.getElementById("results").style.display="inline";'>Add</
    > button>


    There are several fundamental problems with this approach:

    1. The `div' element is not displayed if CSS is supported, support is
    enabled, and client-side script support is not present, is disabled,
    or is insufficient.

    2. The `button' element requires HTML 4.01, while a more compatible

    <input type="button" value="Add"
    onmouseup="document.getElementById('results').style.display='inline';">

    would have sufficed here as the caption is only text.

    3. The button will not work without client-side scripting. As it is not
    written with client-side scripting, when support is insufficient users
    encounter a control that is apparently not working. A Bad Thing.

    4. If client-side scripting is enabled, the button will also be activated
    if one clicks elsewhere and only releases the mouse button over the
    button because that is the definition of the `mouseup' event.

    The button cannot be activated with the keyboard, only with a pointing
    device. By not fulfilling this very basic criterion, the application
    fails to meet standardized accessibility guidelines which are not only
    desirable to meet but are often are required-by-law to meet in order
    for the application to be even considered for public use or use within
    a particular organization.

    `onclick' is the proper event handler attribute to use here, not
    `onmouseup'.

    5. The button will not only not work but throw an exception if for some
    reason sufficient DOM Level 1+ support is not available, as this support
    is required by document.getElementById() and the method has been called
    without prior feature test. This is the case e.g. in MSHTML 5.0, used
    e.g. by Internet Explorer 5.0.

    It will also error out if the method for some reason does not return an
    object reference, as the return value is used untested in a reference
    worm[tm]. The same goes for any other reference along the worm's path.

    6. The `div' element is a block element, not an inline element; the
    default value for its CSS `display' property is `block', not `inline'.

    7. You are showing an infection with DIVitis: An additional `div' element
    that the table is contained in is completely unnecessary; the table
    itself can be hidden (but should only be hidden onload, with the
    same scripting that later shows it):

    <body onload="hideTable()">

    8. Hiding the table does not prevent the whole table from being downloaded
    and parsed although not needed/wanted, which can take quite long and is
    probably not what the OP wants. ISTM they rather want the Add button to
    display the entries that can be used to populate another table, for
    which, as I said before, no client-side scripting is needed at all.

    Considering these facts, I suggest you refrain from suggesting anything
    further in this newsgroup, and to go back to the drawing board, if not your
    student's books instead.


    PointedEars
    --
    Use any version of Microsoft Frontpage to create your site.
    (This won't prevent people from viewing your source, but no one
    will want to steal it.)
    -- from <http://www.vortex-webdesign.com/help/hidesource.htm>
    Thomas 'PointedEars' Lahn, Jul 1, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    0
    Views:
    678
    Guest
    Feb 25, 2004
  2. komal
    Replies:
    6
    Views:
    1,418
    msalters
    Jan 25, 2005
  3. =?Utf-8?B?Q2hyaXM=?=

    Help Help. I really need some help with this

    =?Utf-8?B?Q2hyaXM=?=, Jan 31, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    559
    =?Utf-8?B?SmFzb24gVmVybWlsbGlvbg==?=
    Jan 31, 2007
  4. Domino
    Replies:
    5
    Views:
    376
    dorayme
    Nov 5, 2006
  5. takachi
    Replies:
    0
    Views:
    306
    takachi
    Jan 1, 2008
Loading...

Share This Page