javascript error (dynamic table generation) | Newbie | | Join Date: Feb 2008
Posts: 29
| |
HI,
I am creating a page using javascript and dom. when i go to the new window and press abutton after selecting a option from a dropdown menu the table shoub appear within the same new page .
Here is my piece of code I am not able to pass and print the value of selected option needed to generate a complete table.
======================== - function y()
-
{
-
nwin=open("","","");
-
nwin.document.open();
-
//nwin.document.write(xmlDoc.documentElement.childNodes[0].childNodes[0].text);
-
var it=xmlDoc.documentElement.childNodes[0].getElementsByTagName("item");
-
var le=it.length;
-
nwin.document.write("<form id='f1'><select id='s1'>")
-
for(var i = 0; i <le; i++)
-
{
-
n = it.item(i);
-
nwin.document.write("<option value=\""+i+"\">"+n.childNodes[0].text+"</option>");
-
-
}
-
nwin.document.write("</select><input type='button' value='get details' onclick='fun();'></form>");
-
-
function fun()
-
{
-
var r=document.f1.s1.selectedIndex;
-
var outstring="<b>"+ r +"</b>"
-
document.inside.innerHTML=outstring;
-
}
-
nwin.document.write("<div id='inside'></div>");
-
nwin.document.close();
-
}
Thanks in advance
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: javascript error (dynamic table generation)
First of all, welcome to TSDN!
Re. your problem: how do you call the function and what's the error message and on which line?
| | Newbie | | Join Date: Feb 2008
Posts: 29
| | | re: javascript error (dynamic table generation) Quote:
Originally Posted by acoder First of all, welcome to TSDN!
Re. your problem: how do you call the function and what's the error message and on which line? Thanks for welcome.I check the browser type throuht if then and in evey if or then i call function y.I get object expected error, line 1 char1
Here is the complete code:-
=============================
code(javascipt)
[HTML]<html>
<head>
<script language="javascript">
var xmlDoc;
function showerror(error)
{
ewin=open("","","");
ewin.document.open();
ewin.document.write("<b>XML parsing error</b><br><br>Error#: "+error.errorCode+"<br>Description: "+error.reason+"<br>In file: "+error.url+"<br>Line:$
ewin.document.close();
}
function y()
{
nwin=open("","","");
nwin.document.open();
var it=xmlDoc.documentElement.childNodes[0].getElementsByTagName("item");
var le=it.length;
nwin.document.write("<div id='inside'>sab</div>");
function fun()
{
nwin.document.write("<form id='f1'><select id='s1'>");
for(var i = 0; i <le; i++)
{
n = it.item(i);
nwin.document.write("<option value=\""+i+"\">"+n.childNodes[0].text+"</option>");
}
nwin.document.write("</select>");
var r=document.f1.s1.selectedIndex;
var ChosenTitle = document.f1.s1.options[r].text;
var outtext+="<b>"+ChosenTitle+"</b>"
document.getElementById("inside").innerHTML=outtex t;
}
nwin.document.write("<input type='button' value='get details' onClick='fun();'></form>");
nwin.document.close();
}
function x(file)
{
// code for IE
if (window.ActiveXObject)
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load(file);
if (xmlDoc.parseError.errorCode != 0)
{
showerror(xmlDoc.parseError);
}
else
{
y();
}
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument)
{
xmlDoc=document.implementation.createDocument(""," ",null);
//xmlDoc.load(file);
xmlDoc.async=false;
if(!xmlDoc.load(file))
{
alert('Error in XML file');
}
else
{
y();
}
}
else
{
alert('browser cannot handle this script');
}
xmlDoc.async=false;
}
</script>
</head>
<body>
<form name="form1">
<b>Enter XML File </b><br>
<input type="text" value="" id="t1" size="100" maxlength="100"><br>
<input type="button" value="button" name="button1" onClick="x(t1.value);">
</form>
</body>
</html>[/HTML]
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: javascript error (dynamic table generation)
Why have you declared fun() inside y()?
The error could be more useful if you checked the Firefox error console or Firebug.
Show your XML code too.
| | Newbie | | Join Date: Feb 2008
Posts: 29
| | | re: javascript error (dynamic table generation)
here is the xml file:-
============ - <?xml version="1.0" encoding="UTF-8"?>
-
<!-- generator="wordpress/2.0.5" -->
-
<rss version="2.0"
-
xmlns:content="http://purl.org/rss/1.0/modules/content/"
-
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
-
xmlns:dc="http://purl.org/dc/elements/1.1/"
-
>
-
-
<channel>
-
<title>Bits</title>
-
<link>http://bits.blogs.nytimes.com</link>
-
<description>A New York Times blog</description>
-
<pubDate>Mon, 28 Jan 2008 21:31:41 +0000</pubDate>
-
-
<generator>http://wordpress.org/?v=2.0.5</generator>
-
<language>en</language>
-
<item>
-
<title>The Innovator’s Dilemma of a Toy Maker</title>
-
<link>http://bits.blogs.nytimes.com/2008/01/28/the-innovators-dilemma-of-a-toy-maker/</link>
-
<comments>http://bits.blogs.nytimes.com/2008/01/28/the-innovators-dilemma-of-a-toy-maker/#comments</comments>
-
-
<pubDate>Mon, 28 Jan 2008 21:31:41 +0000</pubDate>
-
<dc:creator>Miguel Helft</dc:creator>
-
-
<dc:subject>Innovations and Ideas</dc:subject><dc:subject>innovators dilemma</dc:subject><dc:subject>LeapFrog</dc:subject>
-
<guid isPermaLink="false">http://bits.blogs.nytimes.com/2008/01/28/the-innovators-dilemma-of-a-toy-maker/</guid>
-
<description><![CDATA[LeapFrog's successor to the best-selling LeapPad, the Tag, is being introduced today. It could have been in toy stores years earlier. ]]></description>
-
<wfw:commentRSS>http://bits.dblogs.nytimes.com/?feed=rss2&p=859</wfw:commentRSS>
-
-
</item>
-
<item>
-
<title>Tracking Consumer Savings on eBay</title>
-
<link>http://bits.blogs.nytimes.com/2008/01/28/tracking-consumer-savings-on-ebay/</link>
-
<comments>http://bits.blogs.nytimes.com/2008/01/28/tracking-consumer-savings-on-ebay/#comments</comments>
-
<pubDate>Mon, 28 Jan 2008 19:15:16 +0000</pubDate>
-
<dc:creator>Brad Stone</dc:creator>
-
-
-
<dc:subject>Internet</dc:subject><dc:subject>EBay</dc:subject><dc:subject>Internet auctions</dc:subject>
-
<guid isPermaLink="false">http://bits.blogs.nytimes.com/2008/01/28/tracking-consumer-savings-on-ebay/</guid>
-
<description><![CDATA[A new study suggests consumers save billions of dollars by shopping on eBay auctions. ]]></description>
-
<wfw:commentRSS>http://bits.dblogs.nytimes.com/?feed=rss2&p=858</wfw:commentRSS>
-
</item>
-
<item>
-
-
<title>Hints That Europe Will Let Google Buy DoubleClick</title>
-
<link>http://bits.blogs.nytimes.com/2008/01/25/hints-that-europe-will-let-google-buy-doubleclick/</link>
-
<comments>http://bits.blogs.nytimes.com/2008/01/25/hints-that-europe-will-let-google-buy-doubleclick/#comments</comments>
-
<pubDate>Fri, 25 Jan 2008 22:47:29 +0000</pubDate>
-
<dc:creator>Saul Hansell</dc:creator>
-
-
<dc:subject>Internet</dc:subject>
-
-
<dc:subject>Online Marketing</dc:subject>
-
<guid isPermaLink="false">http://bits.blogs.nytimes.com/2008/01/25/hints-that-europe-will-let-google-buy-doubleclick/</guid>
-
<description><![CDATA[Reading the tea leaves in Brussels provides clues that the European Commission is preparing to allow Google to buy DoubleClick after a year-long review. ]]></description>
-
<wfw:commentRSS>http://bits.dblogs.nytimes.com/?feed=rss2&p=857</wfw:commentRSS>
-
</item>
-
<item>
-
<title>Ruminating Over Identity at Sundance</title>
-
-
<link>http://bits.blogs.nytimes.com/2008/01/25/ruminating-over-identity-at-sundance/</link>
-
<comments>http://bits.blogs.nytimes.com/2008/01/25/ruminating-over-identity-at-sundance/#comments</comments>
-
<pubDate>Fri, 25 Jan 2008 22:04:04 +0000</pubDate>
-
<dc:creator>Katie Hafner</dc:creator>
-
-
<dc:subject>Technology and Society</dc:subject><dc:subject>Microsoft</dc:subject><dc:subject>MySpace</dc:subject><dc:subject>Reality Sandwich</dc:subject><dc:subject>Sundance</dc:subject>
-
-
<guid isPermaLink="false">http://bits.blogs.nytimes.com/2008/01/25/ruminating-over-identity-at-sundance/</guid>
-
<description><![CDATA[The places young people find online to hang out are less fake than the lives they live with their parents, their teachers, even their real-life friends. It makes their lives more real, said panelists discussing technology and how it changes us. ]]></description>
-
<wfw:commentRSS>http://bits.dblogs.nytimes.com/?feed=rss2&p=855</wfw:commentRSS>
-
</item>
-
<item>
-
<title>Spectrum Auction: Bidders Spurn Frequencies Linked to Public Safety</title>
-
<link>http://bits.blogs.nytimes.com/2008/01/25/spectrum-auction-bidders-spurn-frequencies-linked-to-public-safety/</link>
-
-
<comments>http://bits.blogs.nytimes.com/2008/01/25/spectrum-auction-bidders-spurn-frequencies-linked-to-public-safety/#comments</comments>
-
<pubDate>Fri, 25 Jan 2008 20:02:49 +0000</pubDate>
-
<dc:creator>Saul Hansell</dc:creator>
- <dc:subject>Telecommunications</dc:subject><dc:subject>fcc</dc:subject><dc:subject>spectrum</dc:subject>
-
<guid isPermaLink="false">http://bits.blogs.nytimes.com/2008/01/25/spectrum-auction-bidders-spurn-frequencies-linked-to-public-safety/</guid>
-
-
<description><![CDATA[After four rounds of of the government auction, only a single bid has emerged for the block of frequencies meant to combine national wireless voice and data service with communications for public safety agencies. ]]></description>
-
<wfw:commentRSS>http://bits.dblogs.nytimes.com/?feed=rss2&p=856</wfw:commentRSS>
-
</item>
-
<item>
-
<title>Murdoch Decides to Take WSJ.com’s Money Now</title>
-
<link>http://bits.blogs.nytimes.com/2008/01/25/murdoch-decides-to-take-wsjcoms-money-now/</link>
-
<comments>http://bits.blogs.nytimes.com/2008/01/25/murdoch-decides-to-take-wsjcoms-money-now/#comments</comments>
-
-
<pubDate>Fri, 25 Jan 2008 15:08:23 +0000</pubDate>
-
<dc:creator>Saul Hansell</dc:creator>
-
-
<dc:subject>Internet</dc:subject><dc:subject>Business Models</dc:subject><dc:subject>News Corporation</dc:subject><dc:subject>Wall Street Journal</dc:subject>
-
<guid isPermaLink="false">http://bits.blogs.nytimes.com/2008/01/25/murdoch-decides-to-take-wsjcoms-money-now/</guid>
-
<description><![CDATA[By deciding to keep charging for the online edition of the Wall Street Journal, Rupert Murdoch is putting his interest in making more money ahead of his desire to use the Journal to advocate his conservative political views. ]]></description>
-
-
<wfw:commentRSS>http://bits.dblogs.nytimes.com/?feed=rss2&p=854</wfw:commentRSS>
-
</item>
-
<item>
-
<title>At Sundance, a Second Life Sweatshop Is Art</title>
-
<link>http://bits.blogs.nytimes.com/2008/01/25/at-sundance-a-second-life-sweatshop-is-art/</link>
-
<comments>http://bits.blogs.nytimes.com/2008/01/25/at-sundance-a-second-life-sweatshop-is-art/#comments</comments>
-
-
<pubDate>Fri, 25 Jan 2008 13:58:34 +0000</pubDate>
-
<dc:creator>Katie Hafner</dc:creator>
-
-
<dc:subject>Internet</dc:subject>
-
<dc:subject>Innovations and Ideas</dc:subject><dc:subject>Invisible Threads</dc:subject><dc:subject>second life</dc:subject><dc:subject>Sundance</dc:subject>
-
<guid isPermaLink="false">http://bits.blogs.nytimes.com/2008/01/25/at-sundance-a-second-life-sweatshop-is-art/</guid>
-
-
<description><![CDATA[Want a window into so-called telemetric manufacturing methods of the future? Performance artists at the Sundance Film Festival created a virtual sweatshop in Second Life that makes real jeans. Is it art for money or money for art? ]]></description>
-
<wfw:commentRSS>http://bits.dblogs.nytimes.com/?feed=rss2&p=853</wfw:commentRSS>
-
</item>
-
<item>
-
<title>The Art of Nanotech</title>
-
<link>http://bits.blogs.nytimes.com/2008/01/25/the-art-of-nanotech/</link>
-
<comments>http://bits.blogs.nytimes.com/2008/01/25/the-art-of-nanotech/#comments</comments>
- <pubDate>Fri, 25 Jan 2008 13:55:15 +0000</pubDate>
-
<dc:creator>Barnaby J. Feder</dc:creator>
-
-
<dc:subject>Nanotechnology</dc:subject><dc:subject>art</dc:subject><dc:subject>Cris Orfescu</dc:subject><dc:subject>nanotechnology</dc:subject>
-
<guid isPermaLink="false">http://bits.blogs.nytimes.com/2008/01/25/the-art-of-nanotech/</guid>
-
<description><![CDATA[Nanotechnology is a new medium for art. ]]></description>
-
-
<wfw:commentRSS>http://bits.dblogs.nytimes.com/?feed=rss2&p=851</wfw:commentRSS>
-
</item>
-
<item>
-
<title>Spectrum Auction Day 1: $2.779 Billion in Bids</title>
-
<link>http://bits.blogs.nytimes.com/2008/01/24/spectrum-auction-day-1-2779-billion-in-bids/</link>
-
<comments>http://bits.blogs.nytimes.com/2008/01/24/spectrum-auction-day-1-2779-billion-in-bids/#comments</comments>
-
-
<pubDate>Thu, 24 Jan 2008 23:49:21 +0000</pubDate>
-
<dc:creator>Saul Hansell</dc:creator>
-
-
<dc:subject>Telecommunications</dc:subject><dc:subject>fcc</dc:subject><dc:subject>spectrum</dc:subject>
-
<guid isPermaLink="false">http://bits.blogs.nytimes.com/2008/01/24/spectrum-auction-day-1-2779-billion-in-bids/</guid>
-
<description><![CDATA[Bidding has started for the wireless spectrum that is being abandoned by the move to digital television. So far, it's not clear whether there will be enough interest for the government to receive the $10 billion it wants. ]]></description>
-
<wfw:commentRSS>http://bits.dblogs.nytimes.com/?feed=rss2&p=852</wfw:commentRSS>
-
-
</item>
-
<item>
-
<title>John Donahoe’s Plan to Save eBay: Better Search</title>
-
<link>http://bits.blogs.nytimes.com/2008/01/24/john-donahoes-plan-to-save-ebay-better-search/</link>
-
<comments>http://bits.blogs.nytimes.com/2008/01/24/john-donahoes-plan-to-save-ebay-better-search/#comments</comments>
-
<pubDate>Thu, 24 Jan 2008 19:34:14 +0000</pubDate>
-
<dc:creator>Saul Hansell</dc:creator>
-
-
-
<dc:subject>Internet</dc:subject><dc:subject>EBay</dc:subject><dc:subject>John Donahoe</dc:subject>
-
<guid isPermaLink="false">http://bits.blogs.nytimes.com/2008/01/24/john-donahoes-plan-to-save-ebay-better-search/</guid>
-
<description><![CDATA[The incoming chief executive of eBay, John Donahoe, says he is planning a new search engine to show users the best offers from the best sellers with low prices, fast shipping and high quality. He's also prepared for a wave of protest from sellers whose listings are not featured in the new search results. ]]></description>
-
<wfw:commentRSS>http://bits.dblogs.nytimes.com/?feed=rss2&p=850</wfw:commentRSS>
-
</item>
- <item>
-
-
<title>YouTube On the Go</title>
-
<link>http://bits.blogs.nytimes.com/2008/01/24/youtube-on-the-go/</link>
-
<comments>http://bits.blogs.nytimes.com/2008/01/24/youtube-on-the-go/#comments</comments>
-
<pubDate>Thu, 24 Jan 2008 14:23:56 +0000</pubDate>
-
<dc:creator>Miguel Helft</dc:creator>
-
-
<dc:subject>Internet</dc:subject>
-
-
<dc:subject>Music and Video</dc:subject><dc:subject>Google</dc:subject><dc:subject>Mobile phones</dc:subject><dc:subject>video</dc:subject><dc:subject>YouTube</dc:subject>
-
<guid isPermaLink="false">http://bits.blogs.nytimes.com/2008/01/24/youtube-on-the-go/</guid>
-
<description><![CDATA[YouTube expands its mobile site to make the experience of watching videos on the go more like it is on the PC. ]]></description>
-
<wfw:commentRSS>http://bits.dblogs.nytimes.com/?feed=rss2&p=849</wfw:commentRSS>
-
</item>
-
-
<item>
-
<title>Last.FM Has a First With Streaming Music</title>
-
<link>http://bits.blogs.nytimes.com/2008/01/23/lastfm-is-first-with-streaming-music-users-choose/</link>
-
<comments>http://bits.blogs.nytimes.com/2008/01/23/lastfm-is-first-with-streaming-music-users-choose/#comments</comments>
-
<pubDate>Wed, 23 Jan 2008 15:45:16 +0000</pubDate>
-
<dc:creator>Saul Hansell</dc:creator>
-
-
-
<dc:subject>Music and Video</dc:subject><dc:subject>Business Models</dc:subject><dc:subject>cbs</dc:subject><dc:subject>imeem</dc:subject><dc:subject>last.fm</dc:subject><dc:subject>Music</dc:subject>
-
<guid isPermaLink="false">http://bits.blogs.nytimes.com/2008/01/23/lastfm-is-first-with-streaming-music-users-choose/</guid>
-
<description><![CDATA[Last.FM, the free online radio service owned by CBS, will let users listen to any of 3.5 million songs on demand, paid for with advertising. The key limit: each user can only listen to each song 3 times. ]]></description>
-
<wfw:commentRSS>http://bits.dblogs.nytimes.com/?feed=rss2&p=848</wfw:commentRSS>
-
-
</item>
- <item>
-
<title>Tracking the World’s Appetite for Innovation</title>
-
<link>http://bits.blogs.nytimes.com/2008/01/23/tracking-the-worlds-appetite-for-innovation/</link>
-
<comments>http://bits.blogs.nytimes.com/2008/01/23/tracking-the-worlds-appetite-for-innovation/#comments</comments>
-
<pubDate>Wed, 23 Jan 2008 15:40:09 +0000</pubDate>
-
-
<dc:creator>Steve Lohr</dc:creator>
-
-
<dc:subject>Technology and Society</dc:subject><dc:subject>H P</dc:subject><dc:subject>innovation</dc:subject><dc:subject>knowledge economy</dc:subject><dc:subject>Microsoft</dc:subject><dc:subject>Productivity</dc:subject><dc:subject>Unisys</dc:subject>
-
<guid isPermaLink="false">http://bits.blogs.nytimes.com/2008/01/23/tracking-the-worlds-appetite-for-innovation/</guid>
-
<description><![CDATA[ In its quest for what it calls “new metrics for the knowledge economy,” a nonprofit research group has come up with an index of global innovation confidence.
-
The poll of 25,000 people in a dozen nations, published on Tuesday, found the United States squarely in the middle [...] ]]></description>
-
-
<wfw:commentRSS>http://bits.dblogs.nytimes.com/?feed=rss2&p=846</wfw:commentRSS>
-
</item>
-
<item>
-
<title>Can the Touch Revive Apple’s iPod Sales?</title>
-
<link>http://bits.blogs.nytimes.com/2008/01/22/can-the-touch-revive-apples-ipod-sales/</link>
-
<comments>http://bits.blogs.nytimes.com/2008/01/22/can-the-touch-revive-apples-ipod-sales/#comments</comments>
-
-
<pubDate>Tue, 22 Jan 2008 23:51:11 +0000</pubDate>
-
<dc:creator>Saul Hansell</dc:creator>
-
-
<dc:subject>Consumer Electronics</dc:subject>
-
<dc:subject>Hardware</dc:subject><dc:subject>Apple</dc:subject><dc:subject>ipod</dc:subject>
-
<guid isPermaLink="false">http://bits.blogs.nytimes.com/2008/01/22/can-the-touch-revive-apples-ipod-sales/</guid>
-
-
<description><![CDATA[Despite a 10 percent drop in Apple's shares, the company did very well in the fourth quarter, putting $3 billion in the bank. It plans to address its main weakness--slow growth in iPod sales--by emphasizing the Internet capability of the iPod Touch. ]]></description>
-
<wfw:commentRSS>http://bits.dblogs.nytimes.com/?feed=rss2&p=847</wfw:commentRSS>
-
</item>
-
<item>
-
<title>Europe: Your I.P. Address Is Personal</title>
-
<link>http://bits.blogs.nytimes.com/2008/01/22/europe-your-ip-address-is-personal/</link>
-
<comments>http://bits.blogs.nytimes.com/2008/01/22/europe-your-ip-address-is-personal/#comments</comments>
-
-
<pubDate>Tue, 22 Jan 2008 20:31:20 +0000</pubDate>
-
<dc:creator>Saul Hansell</dc:creator>
-
-
<dc:subject>Policy and Law</dc:subject><dc:subject>Google</dc:subject><dc:subject>Privacy</dc:subject>
-
<guid isPermaLink="false">http://bits.blogs.nytimes.com/2008/01/22/europe-your-ip-address-is-personal/</guid>
-
<description><![CDATA[At a hearing Monday, a top European regulator said that Internet Protocol addresses, which identify computers connected to the Internet, should be treated as personal information, something Google and other sites have resisted. ]]></description>
-
<wfw:commentRSS>http://bits.dblogs.nytimes.com/?feed=rss2&p=845</wfw:commentRSS>
-
-
</item>
-
<item>
-
<title>Report Says Whitman to Leave After Conservative Decade at eBay</title>
-
<link>http://bits.blogs.nytimes.com/2008/01/22/report-says-whitman-to-leave-after-conservative-decade-at-ebay/</link>
-
<comments>http://bits.blogs.nytimes.com/2008/01/22/report-says-whitman-to-leave-after-conservative-decade-at-ebay/#comments</comments>
-
<pubDate>Tue, 22 Jan 2008 16:33:53 +0000</pubDate>
-
<dc:creator>Saul Hansell</dc:creator>
-
-
-
<dc:subject>Internet</dc:subject><dc:subject>EBay</dc:subject><dc:subject>Meg Whitman</dc:subject>
-
<guid isPermaLink="false">http://bits.blogs.nytimes.com/2008/01/22/report-says-whitman-to-leave-after-conservative-decade-at-ebay/</guid>
-
<description><![CDATA[Meg Whitman is about to announce her retirement after a decade running eBay, a report says. The company faces challenges from Google and Amazon, and it may need to make more radical changes than has been the style of the cautious Ms. Whitman. ]]></description>
-
<wfw:commentRSS>http://bits.dblogs.nytimes.com/?feed=rss2&p=844</wfw:commentRSS>
-
</item>
- <item>
-
-
<title>Bits Debate: On the Rights of Readers and Viewers</title>
-
<link>http://bits.blogs.nytimes.com/2008/01/18/bits-debate-on-the-rights-of-readers-and-viewers/</link>
-
<comments>http://bits.blogs.nytimes.com/2008/01/18/bits-debate-on-the-rights-of-readers-and-viewers/#comments</comments>
-
<pubDate>Sat, 19 Jan 2008 03:19:32 +0000</pubDate>
-
<dc:creator>Saul Hansell</dc:creator>
-
-
<dc:subject>Policy and Law</dc:subject><dc:subject>bits debate: copyright</dc:subject><dc:subject>Copyright</dc:subject><dc:subject>fair use</dc:subject>
-
-
<guid isPermaLink="false">http://bits.blogs.nytimes.com/2008/01/18/bits-debate-on-the-rights-of-readers-and-viewers/</guid>
-
<description><![CDATA[Is the march of technology taking away rights people used to enjoy, such as the ability to make personal copies of things they buy? Tim Wu, of Columbia Law School, says technology is eroding the value of ownership. Rick Cotton, of NBC Universal, says new copy protection systems will give more options to consumers. The Bits Debate continues. ]]></description>
-
<wfw:commentRSS>http://bits.dblogs.nytimes.com/?feed=rss2&p=843</wfw:commentRSS>
-
</item>
-
<item>
-
<title>You’re Not Buying Gadgets, You Are Subscribing to Them</title>
-
-
<link>http://bits.blogs.nytimes.com/2008/01/18/youre-not-buying-gadgets-any-more-you-are-subscribing-to-them/</link>
-
<comments>http://bits.blogs.nytimes.com/2008/01/18/youre-not-buying-gadgets-any-more-you-are-subscribing-to-them/#comments</comments>
-
<pubDate>Sat, 19 Jan 2008 00:15:04 +0000</pubDate>
-
<dc:creator>Saul Hansell</dc:creator>
-
-
<dc:subject>Consumer Electronics</dc:subject><dc:subject>Blu ray</dc:subject><dc:subject>digital television</dc:subject><dc:subject>Televisions</dc:subject>
-
-
<guid isPermaLink="false">http://bits.blogs.nytimes.com/2008/01/18/youre-not-buying-gadgets-any-more-you-are-subscribing-to-them/</guid>
-
<description><![CDATA[A new specification will add features to Blu-ray disc players proves that people really just subscribe to consumer electronics rather than buying them. Accept that and you can defend profligate spending on the latest TV or being a penny-pincher. ]]></description>
-
<wfw:commentRSS>http://bits.dblogs.nytimes.com/?feed=rss2&p=842</wfw:commentRSS>
-
</item>
-
<item>
-
<title>Slide Slides Into Some Cash</title>
-
<link>http://bits.blogs.nytimes.com/2008/01/18/slide-slides-into-some-cash/</link>
-
-
<comments>http://bits.blogs.nytimes.com/2008/01/18/slide-slides-into-some-cash/#comments</comments>
-
<pubDate>Fri, 18 Jan 2008 19:25:46 +0000</pubDate>
-
<dc:creator>Brad Stone</dc:creator>
-
-
<dc:subject>Internet</dc:subject>
-
<dc:subject>Silicon Valley</dc:subject>
-
<dc:subject>Venture Capital and Finance</dc:subject>
-
-
<guid isPermaLink="false">http://bits.blogs.nytimes.com/2008/01/18/slide-slides-into-some-cash/</guid>
-
<description><![CDATA[Slide, the maker of applications for social networks, has raised another round of financing – $50 million from the private equity funds at Fidelity and T-Rowe Price. ]]></description>
-
<wfw:commentRSS>http://bits.dblogs.nytimes.com/?feed=rss2&p=841</wfw:commentRSS>
-
</item>
-
<item>
-
<title>A Less Stylish Approach to RFID</title>
-
<link>http://bits.blogs.nytimes.com/2008/01/18/a-less-stylish-approach-to-rfid/</link>
-
-
<comments>http://bits.blogs.nytimes.com/2008/01/18/a-less-stylish-approach-to-rfid/#comments</comments>
-
<pubDate>Fri, 18 Jan 2008 16:10:01 +0000</pubDate>
-
<dc:creator>Barnaby J. Feder</dc:creator>
-
-
<dc:subject>Nanotechnology</dc:subject><dc:subject>I.B.M.</dc:subject><dc:subject>Metro Group</dc:subject><dc:subject>RFID</dc:subject>
-
<guid isPermaLink="false">http://bits.blogs.nytimes.com/2008/01/18/a-less-stylish-approach-to-rfid/</guid>
-
-
<description><![CDATA[Metro Group, the giant German grocery and consumer goods retailer, has been a leader in applying RFID tags to shipments of goods to track their progress through its distribution chain. It is starting a new effort to test if customers will accept tags on clothes. ]]></description>
-
<wfw:commentRSS>http://bits.dblogs.nytimes.com/?feed=rss2&p=838</wfw:commentRSS>
-
</item>
-
</channel>
-
</rss>
| | Newbie | | Join Date: Feb 2008
Posts: 29
| | | re: javascript error (dynamic table generation)
hi,
here is an simple sort of main crux of my main progam if this works then I guess main program wil work .kindly check error in this:-
==========
code(javascript)
UW PICO(tm) 4.0 File: koh.html Modified
[HTML]<HTML>
<head>
<SCRIPT language="javascript">
function insertScript()
{
var c=document.getElementById("f1").s1.options[f1.s1.selectedIndex].text;
var sHTML="<table border='1'>"
sHTML=sHTML+"<tr><td>"+c+"</tr></td>"
sHTML=sHTML+"<tr><td>"+c+"</tr></td>"
sHTML=sHTML+"</table>"
document.getElementById("ScriptDiv").innerHTML =sHTML;
}
function k()
{
nwin=open("","","");
nwin.document.open();
nwin.document.write("<DIV ID='ScriptDiv'></DIV>");
nwin.document.write("<form id='f1'>");
nwin.document.write("<select id='s1'>");
nwin.document.write("<option value=1>one</option>");
nwin.document.write("<option value=2>two</option>");
nwin.document.write("</select>");
nwin.document.write("<input type='button' value='button' onclick='insertScript();'>");
nwin.document.write("</form>");
nwin.document.close();
}
</script>
</head>
<body>
<form>
<input type="button" value="button" onclick="k();">
</form>
</body>
</HTML>[/HTML]
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: javascript error (dynamic table generation)
k() opens a new window and the button within the code calls insertScript(), but insertScript is in the parent page. Either write insertScript in the popup page or call window.opener.insertScript() instead.
| | Newbie | | Join Date: Feb 2008
Posts: 29
| | | re: javascript error (dynamic table generation) Quote:
Originally Posted by acoder k() opens a new window and the button within the code calls insertScript(), but insertScript is in the parent page. Either write insertScript in the popup page or call window.opener.insertScript() instead. if I use window.opener.insertscript new error comes in the line
document.getElementById("f1") has no properties
[Break on this error] var c=this.document.getElementById("f1").s1.options[f1.s1.selectedIndex]...
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: javascript error (dynamic table generation)
If you're going to use s1, then you have to name your select element "s1". Alternatively, just access the select element directly, e.g. - var c = document.getElementById("s1").options[document.getElementById("s1").selectedIndex];
| | Newbie | | Join Date: Feb 2008
Posts: 29
| | | re: javascript error (dynamic table generation) Quote:
Originally Posted by acoder If you're going to use s1, then you have to name your select element "s1". Alternatively, just access the select element directly, e.g. - var c = document.getElementById("s1").options[document.getElementById("s1").selectedIndex];
This code is still not working it has some problem with var c it says var c=document.form1.select1.options[document.form1.select1.selectedIndex].value;
has no properites.I think it cannot acess the selectedindex value from document. I am really confused with the function insertscript is in parent or child window.
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: javascript error (dynamic table generation) Quote:
Originally Posted by yoshimishu This code is still not working it has some problem with var c it says var c=document.form1.select1.options[document.form1.select1.selectedIndex].value;
has no properites. Is your form named "form1" and your select element "select1"?
| | Newbie | | Join Date: Feb 2008
Posts: 29
| | | re: javascript error (dynamic table generation) Quote:
Originally Posted by acoder Is your form named "form1" and your select element "select1"? yes, I am trying for this for a bunch of hours but not getting it
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: javascript error (dynamic table generation) Quote:
Originally Posted by yoshimishu yes, I am trying for this for a bunch of hours but not getting it Can I see your new simple version of the code now?
| | Newbie | | Join Date: Feb 2008
Posts: 29
| | | re: javascript error (dynamic table generation) Quote:
Originally Posted by acoder Can I see your new simple version of the code now? this is simple code it is not displaying when we choose the option from the dropdown and then ckick the button:--
=========================
code(javascript)
[HTML]<html>
<head>
<script type="text/javascript">
function sr()
{
var s="<b>sab</b>"
return s
}
function k()
{
var nwin=open("","name","");
nwin.document.open();
nwin.document.write("<form id='f1' name='form1'>");
nwin.document.write("<select id='s1' name='select1'>");
nwin.document.write("<option value=1>one</option>");
nwin.document.write("<option value=2>two</option>");
nwin.document.write("</select>");
nwin.document.write("<input type='button' value='get details' onclick=document.getElementById('ScriptDiv').inner HTML = sab; >");
nwin.document.write("</form>");
nwin.document.write("<div id='ScriptDiv'>ab</div>");
nwin.document.close();
}
</script>
</head>
<body>
<form>
<input type="button" value="button" onclick="k();">
</form>
</body>
</html>[/HTML]
| | Newbie | | Join Date: Feb 2008
Posts: 29
| | | re: javascript error (dynamic table generation) Quote:
Originally Posted by yoshimishu this is simple code it is not displaying when we choose the option from the dropdown and then ckick the button:--
=========================
code(javascript)
[HTML]<html>
<head>
<script type="text/javascript">
function sr()
{
var s="<b>sab</b>"
return s
}
function k()
{
var nwin=open("","name","");
nwin.document.open();
nwin.document.write("<form id='f1' name='form1'>");
nwin.document.write("<select id='s1' name='select1'>");
nwin.document.write("<option value=1>one</option>");
nwin.document.write("<option value=2>two</option>");
nwin.document.write("</select>");
nwin.document.write("<input type='button' value='get details' onclick=document.getElementById('ScriptDiv').inner HTML = sr(); >");
nwin.document.write("</form>");
nwin.document.write("<div id='ScriptDiv'>ab</div>");
nwin.document.close();
}
</script>
</head>
<body>
<form>
<input type="button" value="button" onclick="k();">
</form>
</body>
</html>[/HTML] I have edited the code document.getElementById('ScriptDiv').innerHTML= sr();
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: javascript error (dynamic table generation)
What error do you get now?
Please use the proper code tags when posting code. To use code tags, use the # button. You can specify the language using =javascript in the opening code tag, e.g. [code=javascript].
| | Newbie | | Join Date: Feb 2008
Posts: 29
| | | re: javascript error (dynamic table generation) Quote:
Originally Posted by acoder What error do you get now?
Please use the proper code tags when posting code. To use code tags, use the # button. You can specify the language using =javascript in the opening code tag, e.g. [code=javascript]. I am not getting any error but the the value inside <div> codes is not changing on pressing the button in new window.
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: javascript error (dynamic table generation)
Change line 22 to: - nwin.document.write("<input type='button' value='get details' onclick=\"document.getElementById('ScriptDiv').innerHTML = window.opener.sr();\" >");
Remember that sr() is in the parent page, so to access it, you need to use window.opener.
| | Newbie | | Join Date: Feb 2008
Posts: 29
| | | re: javascript error (dynamic table generation) Quote:
Originally Posted by acoder Change line 22 to: - nwin.document.write("<input type='button' value='get details' onclick=\"document.getElementById('ScriptDiv').innerHTML = window.opener.sr();\" >");
Remember that sr() is in the parent page, so to access it, you need to use window.opener. I had tried it ealier with window.opener.sr() but it was not displaying the value returned by the function.
| | Newbie | | Join Date: Feb 2008
Posts: 29
| | | re: javascript error (dynamic table generation) Quote:
Originally Posted by yoshimishu I had tried it ealier with window.opener.sr() but it was not displaying the value returned by the function. I am getting crazy with this thing man this dummy code is taking so much time then how long will the origional code take.
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: javascript error (dynamic table generation) Quote:
Originally Posted by yoshimishu I had tried it ealier with window.opener.sr() but it was not displaying the value returned by the function. Did you replace line 22 with the code that I posted earlier? You forgot the (escaped) quotes.
| | Newbie | | Join Date: Feb 2008
Posts: 29
| | | re: javascript error (dynamic table generation) Quote:
Originally Posted by acoder Did you replace line 22 with the code that I posted earlier? You forgot the (escaped) quotes. the sample code is runnign properly and the main program is also running fine but it has some problem. when i call this function it displays table with :- - function sr(v)
-
{
-
var n = xmlDoc.documentElement.childNodes[0].getElementsByTagName("item").item(v);
-
var disp="<table width='90%' bgcolor='pink' border='1'>"
-
disp+="<tr><td>"+n.childNodes[3].text+"</tr></td>"
-
disp+="<tr><td>"+n.childNodes[4].text+"</tr></td>"
-
disp+="<tr><td><a href=\""+n.childNodes[1].text+"\">"+n.childNodeS[1].text+"</tr></td>"
-
disp+="</table>"
-
return disp;
-
}
-
but whrn I edit it with the following coe it shows up fourth row but with a undefined value:- - function sr(v)
-
{
-
var n = xmlDoc.documentElement.childNodes[0].getElementsByTagName("item").item(v);
-
var rm = xmlDoc.getElementsByTagName("description").item(v+1);
-
var disp="<table width='90%' bgcolor='pink' border='1'>"
-
disp+="<tr><td>"+n.childNodes[3].text+"</tr></td>"
-
disp+="<tr><td>"+n.childNodes[4].text+"</tr></td>"
-
disp+="<tr><td><a href=\""+n.childNodes[1].text+"\">"+n.childNodes[1].text+"</tr></td>"
-
disp+="<tr><td>"+rm.text+"</td></tr>"
-
disp+="</table>"
-
return disp;
-
}
-
thanks;
| | Newbie | | Join Date: Feb 2008
Posts: 29
| | | re: javascript error (dynamic table generation) Quote:
Originally Posted by yoshimishu the sample code is runnign properly and the main program is also running fine but it has some problem. when i call this function it displays table with :- - function sr(v)
-
{
-
var n = xmlDoc.documentElement.childNodes[0].getElementsByTagName("item").item(v);
-
var disp="<table width='90%' bgcolor='pink' border='1'>"
-
disp+="<tr><td>"+n.childNodes[3].text+"</tr></td>"
-
disp+="<tr><td>"+n.childNodes[4].text+"</tr></td>"
-
disp+="<tr><td><a href=\""+n.childNodes[1].text+"\">"+n.childNodeS[1].text+"</tr></td>"
-
disp+="</table>"
-
return disp;
-
}
-
but whrn I edit it with the following coe it shows up fourth row but with a undefined value:- - function sr(v)
-
{
-
var n = xmlDoc.documentElement.childNodes[0].getElementsByTagName("item").item(v);
-
var rm = xmlDoc.getElementsByTagName("description").item(v+1);
-
var disp="<table width='90%' bgcolor='pink' border='1'>"
-
disp+="<tr><td>"+n.childNodes[3].text+"</tr></td>"
-
disp+="<tr><td>"+n.childNodes[4].text+"</tr></td>"
-
disp+="<tr><td><a href=\""+n.childNodes[1].text+"\">"+n.childNodes[1].text+"</tr></td>"
-
disp+="<tr><td>"+rm.text+"</td></tr>"
-
disp+="</table>"
-
return disp;
-
}
-
thanks; I have edited this code.Its still not workink
| | Newbie | | Join Date: Feb 2008
Posts: 29
| | | re: javascript error (dynamic table generation) Quote:
Originally Posted by yoshimishu I have edited this code.Its still not workink final code is working on IE after editing the line 4 to -
var rm = xmlDoc.getElementsByTagName("description").item(++v);
code shows an error in FireFox
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: javascript error (dynamic table generation) Quote:
Originally Posted by yoshimishu final code is working on IE after editing the line 4 to -
var rm = xmlDoc.getElementsByTagName("description").item(++v);
code shows an error in FireFox What's the error message?
| | Newbie | | Join Date: Feb 2008
Posts: 29
| | | re: javascript error (dynamic table generation) Quote:
Originally Posted by acoder What's the error message? xmlDoc.documentElement.childNodes[0].getElementsByTagName is not a function
[Break on this error] var it=xmlDoc.documentElement.childNodes[0].getElementsByTagName("item");
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: javascript error (dynamic table generation) Quote:
Originally Posted by yoshimishu xmlDoc.documentElement.childNodes[0].getElementsByTagName is not a function
[Break on this error] var it=xmlDoc.documentElement.childNodes[0].getElementsByTagName("item"); This is usually caused by whitespace. You're assuming that the first child childNodes[0] is not a whitespace (IE ignores whitespace). See this link for more information.
| | Newbie | | Join Date: Feb 2008
Posts: 29
| | | re: javascript error (dynamic table generation) Quote:
Originally Posted by acoder This is usually caused by whitespace. You're assuming that the first child childNodes[0] is not a whitespace (IE ignores whitespace). See this link for more information. I need to change the entire synatx i.e use code like if(nodeType!=1) or there is an shorter way.
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: javascript error (dynamic table generation) Quote:
Originally Posted by yoshimishu I need to change the entire synatx i.e use code like if(nodeType!=1) or there is an shorter way. Remove the whitespace in your XML.
| | Newbie | | Join Date: Feb 2008
Posts: 29
| | | re: javascript error (dynamic table generation) Quote:
Originally Posted by acoder Remove the whitespace in your XML. Hey I am getting the code right in FF but IE shows some error when I add this line: - disp+="<tr><td>Author</td><td>"+n.getElementsByTagNameNS("http://purl.org/
-
dc/elements/1.1/","creator")[0].firstChild.nodeValue+"</tr></td>"
IE says document does not support this property.
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: javascript error (dynamic table generation) Quote:
Originally Posted by yoshimishu Hey I am getting the code right in FF but IE shows some error when I add this line: - disp+="<tr><td>Author</td><td>"+n.getElementsByTagNameNS("http://purl.org/
-
dc/elements/1.1/","creator")[0].firstChild.nodeValue+"</tr></td>"
IE says document does not support this property. I don't think IE supports namespaces - you'll have to stick to getElementsByTagName only.
|  | Similar JavaScript / Ajax / DHTML bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,449 network members.
|