Fedora Linux Support Community & Resources Center
  #1  
Old 8th January 2007, 10:31 PM
Tux_in_Redhat's Avatar
Tux_in_Redhat Offline
Registered User
 
Join Date: Jan 2007
Posts: 166
Post JavaScript write() method

I am tring to write a function for creating a table with two collumns in it. For one row I have the following code:
Code:
//tR takes two strings and places them on the same row
function tR(var str1, var str2){
  with (document){
    write("<tr><td valign = top>" + str1);
    write("</td><td valign = top>" + str2);
    write("</td></tr>");
  }
}
I placed that inside the file src.js. At the same time I had an HTML file with the code
Code:
<script src = "src.js" language = "JavaScript">
  tR("Column 1", "Column 2");
</script>
However, nothing shows up. I've had trouble with the with-document-write thing before, and it's about time I got it resolved.
__________________
There's no such thing as a stupid computer...
...Just Widnows Vista.
:rolleyes:
Note: I have FC5 with no Internet and a small 5G hard drive( :( )
I would prefer to have .rpm packages, but for simple stuff (like tutorials), .tar.gz type files are good.
Reply With Quote
  #2  
Old 8th January 2007, 11:02 PM
pete_1967 Offline
Clueless in a Cuckooland
 
Join Date: Mar 2006
Location: Here now, elsewhere tomorrow.
Posts: 3,929
document.write
Reply With Quote
  #3  
Old 30th January 2007, 08:23 PM
Tux_in_Redhat's Avatar
Tux_in_Redhat Offline
Registered User
 
Join Date: Jan 2007
Posts: 166
I did that, two. Anyway, it doesn't matter if I say "write" or "document.write". Javascript assumes that "document" is before "write". And that's right.
__________________
There's no such thing as a stupid computer...
...Just Widnows Vista.
:rolleyes:
Note: I have FC5 with no Internet and a small 5G hard drive( :( )
I would prefer to have .rpm packages, but for simple stuff (like tutorials), .tar.gz type files are good.
Reply With Quote
  #4  
Old 5th February 2007, 10:38 PM
Tux_in_Redhat's Avatar
Tux_in_Redhat Offline
Registered User
 
Join Date: Jan 2007
Posts: 166
Anybody have any suggestions?
I've even tried this with the tR() in the same file.
__________________
There's no such thing as a stupid computer...
...Just Widnows Vista.
:rolleyes:
Note: I have FC5 with no Internet and a small 5G hard drive( :( )
I would prefer to have .rpm packages, but for simple stuff (like tutorials), .tar.gz type files are good.
Reply With Quote
  #5  
Old 7th February 2007, 10:45 PM
Aewyn Offline
Registered User
 
Join Date: Apr 2005
Posts: 12
First of all, the parameter list shouldn't have "var" in it, so it should look like this:

Code:
function tR(str1, str2){
Second, the function call can't be in the same SCRIPT element that refers to src.js, since it would be ignored then.

In order to make the HTML valid there should also be a type="text/javascript" attribute in the SCRIPT start tags, and it's probably more correct to use DOM manipulation instead of document.write, but the above two changes seem sufficient to make it show up in Firefox and Opera, at least.
Reply With Quote
Reply

Tags
javascript, method, write

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Fun with Javascript ibbo Wibble 2 31st January 2007 03:13 PM
Javascript panch01 Programming & Packaging 2 30th September 2005 07:18 PM
Javascript mdk3 Servers & Networking 7 15th September 2005 03:33 AM


Current GMT-time: 15:52 (Thursday, 23-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat