Freelancers Network
 
skill list top cap
Homepage
Join the Freelancer's Network
Update your details
Find a freelancer
Post a project
Find a project
Projects Archive
Post a job
Find a job
Jobs Archive
See Dan's Pages
See Andy's Pages
Link to this site
Resources
Join/Leave Forum
Forum Messages
+Additions+ Adverts
Advertising
Contact Us
Subscribe to our newsletter - enter your email address and hit return
Freelancers.net is owned and operated by Andy Stowell and Dan Winchester
skill list end cap
guru web hostcom

Find me again on Freelancers.net

Re: FN-FORUM: Check box problem

date posted 19th March 2008 11:06

On March 19, 2008 11:55 AM, Pam wrote:
>
> Strange isn't it
>
> This is the Check box
>
>
> diaries?" Text="All Diary's">
>
>
> This is the bit of code
>
>
> function Check_Diary_Validate(source, arguments) {
> arguments.IsValid = false
> if (document.getElementById("ALL_Diaries") !== null) {
> if (document.getElementById("ALL_Diaries").Checked == true) {
> arguments.IsValid = true
> }
> }
>
> This bit works
>
> if (document.getElementById("ALL_Diaries").Checked == true
>
> But is doesn't get passed
>
> if (document.getElementById("ALL_Diaries") !== null) {
>
> because document.getElementById("ALL_Diaries") is null
>
>
>
> Pam

The asp.net code is:



but what does the code on the client look like? That is especially
important when you're using master pages and / or grouping checkboxes or
radio buttons.

When creating a group of radio buttons or check boxes, I think asp.net by
default creates a table with an id="All_Diaries". Inside the table it
creates, for each row, the individual checkbox elements with ids like
id="All_Diaries0", "All_Diaries1", etc.

The lesson to be learned is:
1) When using javascript with asp.net controls always 'view-source' of your
html.
2) Don't use the default asp.net controls. Use the css-friendly ones.
Css-friendly controls are a breeze to install and much easier to work with
if you're looking for consistent cross-browser display results.

PS: The link James explained it. In general, with javascript, always create
the element first with:
var x = document.getElementById('blah');

The id used by asp.net and the client are only the same, in the browser
source, sometimes. Often times they are different.

In the example above, to get the actual id as seen by the browser, it would
usually be done like this:
var x = document.getElementById('');

Then do something with it:
if(x) {// code which does somethign to x}

Don't do this:
document.getElementById('blah').style.display = 'none';
Or stuff like that because. 1) you don't know whether it's there and 2)
sometimes you can't change the properties like that anyway.




Messages by Day
March 31st 2008
March 30th 2008
March 29th 2008
March 28th 2008
March 27th 2008
March 26th 2008
March 25th 2008
March 24th 2008
March 23rd 2008
March 22nd 2008
March 21st 2008
March 20th 2008
March 19th 2008
March 18th 2008
March 17th 2008
March 16th 2008
March 15th 2008
March 14th 2008
March 13th 2008
March 12th 2008
March 11th 2008
March 10th 2008
March 9th 2008
March 8th 2008
March 7th 2008
March 6th 2008
March 5th 2008
March 4th 2008
March 3rd 2008
March 2nd 2008
March 1st 2008


Messages by Month
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008


Messages by Year
2008
2007
2006
2005
2004
2003
2002
2001
2000