Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > need some help to write a javascript function

Reply
Thread Tools

need some help to write a javascript function

 
 
adi
Guest
Posts: n/a
 
      06-30-2008
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
 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      06-30-2008
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
 
Reply With Quote
 
 
 
 
yukabuk
Guest
Posts: n/a
 
      07-01-2008
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").styl e.display="inline";'>Add</
button>

Graham
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      07-01-2008
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").styl e.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').styl e.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>
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you write JavaScript in document.write and have it workproperly? Frank Peterson Javascript 9 06-28-2009 03:43 AM
I need some help with a program which makes calculations that I'm suppose to write takachi C Programming 0 01-01-2008 12:07 PM
Need some help fixing some HTML and CSS problems Domino HTML 5 11-05-2006 09:58 PM
write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter komal C++ 6 01-25-2005 11:13 AM
Need some help for some perl homework.... Perl 0 02-25-2004 01:45 AM



Advertisments