User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 455,974 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,807 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1523 | Replies: 2 | Solved
Reply
Join Date: Nov 2007
Posts: 2
Reputation: klefevre is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
klefevre klefevre is offline Offline
Newbie Poster

Help Firefox, javascript and document object

  #1  
Nov 29th, 2007
The following code snippet works in IE, but not Firefox 2.0.0.10. The parts that access text boxes work great. I can see the selectedIndex's value for the two drop-downs, but cannot retrieve the text of the selected item for either drop-down. Specifically, the first alert displays the value of the URL string to that point. The second alert doesn't display.

I would really appreciate any help with this one!

var URL = "http://www.rms4sd.com/media_and_resource_center/dev/inputResource.pl?date=" + document.data_entry.date.value;
URL += "&title=" + document.data_entry.media_title.value;
URL += "&URL=" + document.data_entry.URL.value;
alert(URL);

URL += "&topic=" + document.data_entry.topic.options(document.data_entry.topic.selectedIndex).text;
URL += "&format=" + document.data_entry.format.options(document.data_entry.format.selectedIndex).text ;
alert(URL);
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 7,009
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 25
Solved Threads: 368
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Lazy, Useless & Apathetic

Re: Firefox, javascript and document object

  #2  
Nov 30th, 2007
Read this.

As far as your problem is concerned,
document.data_entry.topic.options(document.data_entry.topic.selectedIndex).text; should be document.data_entry.topic.options[document.data_entry.topic.selectedIndex].value ;

The above way of referencing form elements is pretty inefficient and partly incorrect which is what the tutorial I posted aims at explaining.
I don't accept change. I don't deserve to live.

Happiness corrupts people.

Failing to value the lives of others cheapens your own.
Reply With Quote  
Join Date: Nov 2007
Posts: 2
Reputation: klefevre is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
klefevre klefevre is offline Offline
Newbie Poster

Re: Firefox, javascript and document object

  #3  
Dec 1st, 2007
Thanks for your excellent tutorial on accessing the elements of a form! Thanks also for pointing out my referencing error.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 9:16 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC