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 425,973 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 1,684 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: 1707 | Replies: 10
Reply
Join Date: Mar 2008
Posts: 153
Reputation: Suomedia is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 19
Suomedia Suomedia is offline Offline
Junior Poster

Re: FF vs IE dhtml/javascript/forms issue

  #11  
Mar 17th, 2008
No, its not correct to state that (look at my dev site again, it is full of page elements "pulled via Ajax" and accessed by javascript). You just wont find the element using getElementById etc.

For example, lets say I have the following form, loaded into the page using Ajax:

<form name="elemTest" id="elemTest" onsubmit="return checkCheckBoxes();" action="">
<input type="checkbox" name="box_1" value="1">1</p>
<input type="checkbox" name="box_2" value="2">2</p>
<input type="checkbox" name="box_3" value="3">3</p>
<input type="submit" value="Submit" />
</form>

On my main page that the Ajax content is loaded into, the following will work in IE but not Firefox and others:

<SCRIPT TYPE="text/javascript">
<!--
function checkCheckBoxes() {
	var dname = document.getElementById('elemtest');
	if (dname.box_1.checked == false &&
	    dname.box_2.checked == false &&
	    dname.box_3.checked == false)
		{
		alert ('Please choose one of the checkboxes!');
		return false;
		}
	else
		{
		return true;
		}
	}
//-->
</SCRIPT>

While this will work in all:

<SCRIPT TYPE="text/javascript">
<!--
function checkCheckBoxes() {
	if (document.elemTest.box_1.checked == false &&
	    document.elemTest.box_2.checked == false &&
	    document.elemTest.box_3.checked == false)
		{
		alert ('Please choose one of the checkboxes!');
		return false;
		}
	else
		{
		return true;
		}
	}
//-->
</SCRIPT>


HTH

Matti Ressler
Suomedia
Last edited by Suomedia : Mar 17th, 2008 at 7:39 pm.
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

Other Threads in the JavaScript / DHTML / AJAX Forum

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