473,289 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

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 2360
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Sugapablo | last post by:
I had an idea for something that I can't find any evidence if it exists, or if it can be done. I assume it can be done. What I'd like to be able to do, is to allow people who come to my website,...
28
by: Daniel | last post by:
Hello =) I have an object which contains a method that should execute every x ms. I can use setInterval inside the object construct like this - self.setInterval('ObjectName.methodName()',...
6
by: S P Arif Sahari Wibowo | last post by:
Hi! I am thinking to have a client-side script doing processing on file downloading, basically the script will process a downloaded file from the server before it received by the user. For...
2
by: milkyway | last post by:
Hello again, I am still trying to learn/understand all of this. I thought that by following the suggestion mentioned on the web site below would allow me to pass values to the server. In other...
13
by: Paul | last post by:
Hi I have a .net application that shows the start page for a few seconds and then goes to another start page. I was wondering if it would be possible to put a count on the page to let the user...
8
by: GS | last post by:
Guys: I have a question, Is it possible to implement pop-up window without Java script, we don't want to use java script since it might get blocked by pop-up blocker. Thanks in advance. GS.
40
by: navti | last post by:
I saw here http://java.sun.com/javase/6/docs/technotes/tools/share/jsdocs/index.html that javascript has built-in methods such as cp, dir, date etc how do i get these to run on the client...
14
by: DavidNorep | last post by:
I do not know PHP, consider to write a CGI with this technology and have the following question. Is it possible to invoke a PHP script and let it endlessly wait for requests from a website (a...
7
by: Samuel A. Falvo II | last post by:
I have a shell script script.sh that launches a Java process in the background using the &-operator, like so: #!/bin/bash java ... arguments here ... & In my Python code, I want to invoke...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.