468,106 Members | 1,507 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,106 developers. It's quick & easy.

Is it possible to do followng using java script?

I worked on web development using java script many many years, so I am
now a newbie to javascript. I have a single html page, which is
generated dynamically using some programming language.

Web page will be viewed using Microsoft's IE browser (version 6.x
....). Webapge is self-contained. i.e., it does not refer to any links
outside the webpage, however, it uses
bookmarks inside the same page.

I have a long table to display, table has 50 columns or so. What I want
to do to show
10 columns of the table. 11th column will have a link (more
information). When one clicks
on the link, I will like to dynamically generate another table, which
has 10 more columns and so on.

1. Is there a way to specify in a link to call a java script inside
that page? If yes, how to
do that.
2. When java script is called, can it dynamically generate a table and
display it in a pop-up window. How to do this?
Thanks a lot.

Jul 10 '06 #1
8 2062
This HTML is an example of what you are after. It uses the "document.write" which is not highly regarded, but in this case may work well providing you know the content of the table you are wanting to generate in advance.

If the content of the table is based on user input, then you may want to look into the "document.createElement" method.

[HTML]
<HTML>
<BODY>
<SCRIPT>
function run()
{
var w = window.open('','test','resizable=no,height=400,wid th=400,toolbar=0,scrollbars=no');
w.document.open();
w.document.write("<HTML><HEAD><TITLE>test</TITLE></HEAD><BODY><TABLE border=1><TR><TD>your table</TD></TR></TABLE></BODY></HTML>");
w.document.close();
}
</SCRIPT>
<INPUT type="button" value="test" onclick="run()">
</BODY>
</HTML>
[/HTML]



I worked on web development using java script many many years, so I am
now a newbie to javascript. I have a single html page, which is
generated dynamically using some programming language.

Web page will be viewed using Microsoft's IE browser (version 6.x
....). Webapge is self-contained. i.e., it does not refer to any links
outside the webpage, however, it uses
bookmarks inside the same page.

I have a long table to display, table has 50 columns or so. What I want
to do to show
10 columns of the table. 11th column will have a link (more
information). When one clicks
on the link, I will like to dynamically generate another table, which
has 10 more columns and so on.

1. Is there a way to specify in a link to call a java script inside
that page? If yes, how to
do that.
2. When java script is called, can it dynamically generate a table and
display it in a pop-up window. How to do this?


Thanks a lot.
Jul 10 '06 #2
Hi dba,
1. Is there a way to specify in a link to call a java script inside
that page? If yes, how to
do that.
<a href="#" onclick="myFunction(); return false;">My link</a>
2. When java script is called, can it dynamically generate a table and
display it in a pop-up window. How to do this?
function popupAndShow() {
win = window.open('about:blank', '_popup', null);
win.focus();
// if the popup was already opened, this will
// set it to the foreground
win.document.open();
win.document.writeln('<html><head><title>Table</title></head>
win.document.writeln('<body><table>');
win.document.writeln('<tr><td>Hello world</td></tr>');
win.document.writeln('</table></body></html>');
win.document.close();
}

Greetings,
Vincent
Jul 10 '06 #3
db*********@hotmail.com writes:
I worked on web development using java script many many years, so I am
now a newbie to javascript.
Well, first things first: Javascript is in one word. In two words, it
sounds like it has something to do with the "Java" language, which
it doesn't. :)
I have a single html page, which is generated dynamically using some
programming language.
Well, the client doesn't care how the page was created, just what
*it* sees.
Web page will be viewed using Microsoft's IE browser (version 6.x
...). Webapge is self-contained. i.e., it does not refer to any
links outside the webpage, however, it uses bookmarks inside the
same page.
I assume "bookmark" is a link to a fragment, i.e.,
<a href="#someIdInPage">goto foo</a>
I have a long table to display, table has 50 columns or so. What I want
to do to show
10 columns of the table. 11th column will have a link (more
information). When one clicks
on the link, I will like to dynamically generate another table, which
has 10 more columns and so on.
First of all, I'd recommend using a button, not a link. It is not
linking to anything, it's just doing something.

You might want to extend the existing table instead of creating a new
one.
1. Is there a way to specify in a link to call a java script inside
that page? If yes, how to
do that.
Using a link (with a default action if Javascript is disabled):

<a href="#javascriptNotEnabled" onclick="myJavascript()">More info</a>
...

<noscript id="javascriptNotEnabled">
This page requires Active Scripting (Javascript) to be enabled.
It is currently disabled. Please change the setting and reload
the page.
</noscript>

Using a button:
<input type="button" value="More info" onclick="myJavascript()">

The Javascript to call must have been declared, either in an external
file and included:
<script type="text/javascript" src="externalFile.js"></script>
or directly in the page:
<script type="text/javascript">
//...
function myJavascript() {
...
</script>

2. When java script is called, can it dynamically generate a table and
display it in a pop-up window. How to do this?
It is possible, but somewhat complicated.

/** data : array of arrays of cell data, with first array being headers */
function popupTable(data,windowFlags) {
var html = ["<title>More information</title><table>"]
for (var i = 0; i < data.length; i++) {
html.push("<tr>");
var row = data[i];
for (var j = 0; j < row.length; j++) {
html.push((i == 0)?"<th>":"<td>");
html.push(row[j]);
html.push((i == 0)?"<\/th>":"<\/td>");
}
html.push("<\/tr>\n");
}
html.push("</table>");
var htmlString = html.join("").replace(/([\\"])/g,"\\$1");
window.open("javascript:\""+htmlString+"\"","_blan k", windowFlags);
}

Example use:

popupTable([["horse","rabbit","aardvark","ostrich"],
["beef","stew","pie","omelet"],
["+","-","*","/"]], "width=240,height=200");

Good luck
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 10 '06 #4
What is the source of the tables? Is it pulling datastore information
from the server, or is it static information that you just want to
partially show?

Jul 10 '06 #5
Sevinfooter said the following on 7/10/2006 1:28 PM:

Question: How can you spot a Google poster?
Answer: I would tell you but I would have to quote it.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.

<URL: http://www.safalra.com/special/googlegroupsreply/ >
What is the source of the tables?
The "source" of all tables are HTML when displayed in a webpage.
Is it pulling datastore information from the server, or is it
static information that you just want to partially show?
Let me guess, we will see the "AJAX" buzz word if its information from
the server?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 10 '06 #6

Vincent van Beveren wrote:
Hi dba,
1. Is there a way to specify in a link to call a java script inside
that page? If yes, how to
do that.

<a href="#" onclick="myFunction(); return false;">My link</a>
2. When java script is called, can it dynamically generate a table and
display it in a pop-up window. How to do this?

function popupAndShow() {
win = window.open('about:blank', '_popup', null);
win.focus();
// if the popup was already opened, this will
// set it to the foreground
win.document.open();
win.document.writeln('<html><head><title>Table</title></head>
win.document.writeln('<body><table>');
win.document.writeln('<tr><td>Hello world</td></tr>');
win.document.writeln('</table></body></html>');
win.document.close();
}

Greetings,
Vincent
There is no web-server involved. I have a perl program which generates
this page by getting information from database etc. The script prepare
a self-contained .html file which has all java script and other htnl
code and then look at the page in Microosft IE.
Thanks a lot to all of you for providing quick response. I got the
information which I was looking. This group is very helpful.

Jul 10 '06 #7
JRS: In article <UJ******************************@comcast.com>, dated
Mon, 10 Jul 2006 15:42:36 remote, seen in news:comp.lang.javascript,
Randy Webb <Hi************@aol.composted :
>
The "source" of all tables are HTML when displayed in a webpage.
(A) "is".

(B) No. My <URL:http://www.merlyn.demon.co.uk/estr-bcp.htm#T2shows a
table which is not in any real way HTML (only in so far as the textarea
which contains it is an HTML construct and the javascript which computes
it lives within HTML tags). A visible table is not necessarily a
<table>.

(C) ISTM that "sevinfooter" wanted the /fons et origo/ of the
information content, without much interest in its representation.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 11 '06 #8
I have a long table to display, table has 50 columns or so. What I want
to do to show
10 columns of the table. 11th column will have a link (more
information). When one clicks
on the link, I will like to dynamically generate another table, which
has 10 more columns and so on.
So I suppose you decide to limit it to 10 because it's long.?
Try the easy solution, restrict the tbody's size.

<table style="height: 11em;">
<thead><tr><th>my head, your head</th></tr></thead><!-- 1.2333em -->
<tbody style="height: 10em; overflow: scroll;"><!-- all of your rows,
but only 10em visible --></tbody>
</table>
Thanks a lot.
De nada
Niels

Jul 11 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Sugapablo | last post: by
28 posts views Thread by Daniel | last post: by
6 posts views Thread by S P Arif Sahari Wibowo | last post: by
2 posts views Thread by milkyway | last post: by
13 posts views Thread by Paul | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.