473,385 Members | 1,693 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,385 software developers and data experts.

Disabling elements on load

Rob
Does anybody see anything wrong ith this code? I want to have the
elements disabled on load by default and it doesn't seem to work this
way.

Thanks
Rob

<script language="Javascript">
<!--
window.onload(DisableElements());

function DisableElements(){
document.forms[0].RepContactDemographic_2_1.disabled = true;
document.forms[0].RepFlightTravelArriveDate_1.disabled = true;
document.forms[0].RepFlightTravelDepartDate_1.disabled = true;
document.forms[0].RepContactDemographic_3_1.disabled = true;
document.forms[0].RepContactDemographic_4_1.disabled = true;
document.forms[0].RepDepartureCity_1.disabled = true;

}

//-->
</script>

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #1
2 2391
Rob <rv******@hotmail.com> writes:
Does anybody see anything wrong ith this code? I want to have the
elements disabled on load by default and it doesn't seem to work this
way. .... <script language="Javascript"> Should be
<script type="text/javascript">
The type attribute is required by HTML 4, and is always sufficient.
<!--
HTML-comments are not needed here.
window.onload(DisableElements());
This code immediately calls the window's onload property with an
argument that is the return value of calling DisableElements.
What you probably meant was:
---
window.onload = DisableElements;
---
There should be no calling of functions yet.
function DisableElements(){
document.forms[0].RepContactDemographic_2_1.disabled = true;
document.forms[0].RepFlightTravelArriveDate_1.disabled = true;


I would create a variable referring to the form (or event its elements
collection) insted of finding it froms cratch for each line:

var formElems = document.forms[0].elements;
formElems['RepContactDemographic_2_1'].disabled = true;
formElems['RepFlightTravelArriveDate_1'].disabled = true;
...

/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 23 '05 #2
Rob

Thank you, works like a charm.

Rob
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Simon | last post by:
Newbie to js - I want to disable all elements on a page whilst a new page is loading. Is it possible to enumerate the elements dynamically and disable them? Thanks IA, Simon
3
by: Perttu Pulkkinen | last post by:
What si the best and MOST BROWSERCOMPATIBLE way of making elements disabled for the user? Also considering different kind of elements: textfields, selects, radiobuttons and textareas. This is what...
5
by: Dani | last post by:
Hello everybody, I have some code that disables form elements on body load, but I notice when I hit the "back" button, I need to re-enable the form elements (that is done by clicking on a radial...
12
by: Pudlik, Szymon | last post by:
Hi, I've written some code: function onSubmit(form){ for (var i = 0; i < form.elements.lenght; i++){ if (form.elements.disabled == 1) form.elements.disabled = 0; }
4
by: omidmottaghi | last post by:
I need to disable/enable form elements in my form. the code i was developed works fine in FF, but in IE, its behaviour is very strange!! in the form, we have a lot of checkboxes, all of them...
2
by: dougawells | last post by:
Hi- I'm wanting to have a set of radio buttons disabled when a form is displayed, then if they check another specific radio button, those would become enabled. I've tried setting it via...
7
by: Varangian | last post by:
Hello I want to disable all the elements which are the childs of a Div element. I tried disabling the div element but it doesn't work... i.e. the child elements were not disabled what shal...
11
by: shankwheat | last post by:
I have a function which passes text from txtdebt to debtsbox which works fine. However, I want to add code which examines the value of debtsbox and if any of the values the user entered contain the...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.