473,396 Members | 2,076 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,396 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 2364
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.