why wont my function 'EnableValidators' fire?

D

Dufus

<a id="MyDataList__ctl1_edit_Button" NAME="edit_Button"
OnMousedown="EnableValidators('editGroup_');" href="javascript:{if
(typeof(Page_ClientValidate) != 'function' || Page_ClientValidate())
__doPostBack('MyDataList$_ctl1$edit_Button','')} ">Edit</a>

In the above example, the function 'EnableValidators' does not fire. Has it
got something to do with the fact the id and name attributes are different?
I am unable to make the id and name attributes the same so is there anything
I can do to get it to work?

Thanks in advance.
 
L

Lee

Dufus said:
<a id="MyDataList__ctl1_edit_Button" NAME="edit_Button"
OnMousedown="EnableValidators('editGroup_');" href="javascript:{if
(typeof(Page_ClientValidate) != 'function' || Page_ClientValidate())
__doPostBack('MyDataList$_ctl1$edit_Button','')} ">Edit</a>

In the above example, the function 'EnableValidators' does not fire. Has it
got something to do with the fact the id and name attributes are different?
I am unable to make the id and name attributes the same so is there anything
I can do to get it to work?

What makes you think that EnableValidators() isn't being called?
Maybe that function isn't working.
 
D

Dufus

Lee said:
Dufus said:

What makes you think that EnableValidators() isn't being called?
Maybe that function isn't working.

it works because I have stripped it down to just an alert box and have
successfully called it from elsewhere.
 
R

RobG

Dufus said:
<a id="MyDataList__ctl1_edit_Button" NAME="edit_Button"
OnMousedown="EnableValidators('editGroup_');" href="javascript:{if
(typeof(Page_ClientValidate) != 'function' || Page_ClientValidate())
__doPostBack('MyDataList$_ctl1$edit_Button','')} ">Edit</a>

In the above example, the function 'EnableValidators' does not fire. Has it
got something to do with the fact the id and name attributes are different?
I am unable to make the id and name attributes the same so is there anything
I can do to get it to work?

From the HTML spec at W3C.org:

"The id and name attributes share the same name space. This means that
they cannot both define an anchor with the same name in the same
document. It is permissible to use both attributes to specify an
element's unique identifier for the following elements: A, APPLET,
FORM, FRAME, IFRAME, IMG, and MAP. *When both attributes are used on a
single element, their values must be identical.*" (my emphasis).

<URL: http://www.w3.org/TR/html4/struct/links.html#h-12.2.3>

As for the rest of your element...

Not sure what you are trying to achieve. If your intention is for
EnableValidators to run onmousedown, then for the script attached to
the href to execute, it does not work in all browsers. Safari (and
maybe others) will not run the script on the href if another function
fires (onclick, onmousedown, etc.).

The usual idea is to have the href go to a useful page for those with
JavaScript disabled, then have the onmousedown end with

return false;

which stops the browser from following the href link if javascript is
enabled.

Then add the script you have on the href to the end of the onmousedown:

<a id="MyDataList__ctl1_edit_Button" NAME="edit_Button"
href="aUsefulPage.html"
OnMousedown="
EnableValidators('editGroup_');
if (typeof(Page_ClientValidate) != 'function' ||
Page_ClientValidate())
__doPostBack('MyDataList$_ctl1$edit_Button','');
return false;
">Edit</a>

The above is utterly untested 'cos I have no idea what all your
functions are, however the syntax should be correct.

Rob.
 
F

Fred Oz

Dufus said:
<a id="MyDataList__ctl1_edit_Button" NAME="edit_Button"
OnMousedown="EnableValidators('editGroup_');" href="javascript:{if
(typeof(Page_ClientValidate) != 'function' || Page_ClientValidate())
__doPostBack('MyDataList$_ctl1$edit_Button','')} ">Edit</a>

In the above example, the function 'EnableValidators' does not fire. Has it
got something to do with the fact the id and name attributes are different?
I am unable to make the id and name attributes the same so is there anything
I can do to get it to work?

From the HTML spec at W3C.org:

"The id and name attributes share the same name space. This means that
they cannot both define an anchor with the same name in the same
document. It is permissible to use both attributes to specify an
element's unique identifier for the following elements: A, APPLET,
FORM, FRAME, IFRAME, IMG, and MAP. *When both attributes are used on a
single element, their values must be identical.*" (my emphasis).

<URL: http://www.w3.org/TR/html4/struct/links.html#h-12.2.3>

As for the rest of your element...

Not sure what you are trying to achieve. If your intention is for
EnableValidators to run onmousedown, then for the script attached to
the href to execute, it does not work in all browsers. Safari (and
maybe others) will not run the script on the href if another function
fires (onclick, onmousedown, etc.).

The usual idea is to have the href go to a useful page for those with
JavaScript disabled, then have the onmousedown end with

return false;

which stops the browser from following the href link if javascript is
enabled.

Then add the script you have on the href to the end of the onmousedown:

<a id="MyDataList__ctl1_edit_Button" NAME="edit_Button"
href="aUsefulPage.html"
OnMousedown="
EnableValidators('editGroup_');
if (typeof(Page_ClientValidate) != 'function' ||
Page_ClientValidate())
__doPostBack('MyDataList$_ctl1$edit_Button','');
return false;
">Edit</a>

The above is utterly untested 'cos I have no idea what all your
functions are, however the syntax should be correct, except I haven't
fixed your invalid id/name combination.

Rob.
 
R

RobG

Dufus said:
<a id="MyDataList__ctl1_edit_Button" NAME="edit_Button"
OnMousedown="EnableValidators('editGroup_');" href="javascript:{if
(typeof(Page_ClientValidate) != 'function' || Page_ClientValidate())
__doPostBack('MyDataList$_ctl1$edit_Button','')} ">Edit</a>

In the above example, the function 'EnableValidators' does not fire. Has it
got something to do with the fact the id and name attributes are different?
I am unable to make the id and name attributes the same so is there anything
I can do to get it to work?


From the HTML spec at W3C.org:

"The id and name attributes share the same name space. This means that
they cannot both define an anchor with the same name in the same
document. It is permissible to use both attributes to specify an
element's unique identifier for the following elements: A, APPLET,
FORM, FRAME, IFRAME, IMG, and MAP. *When both attributes are used on a
single element, their values must be identical.*" (my emphasis).

<URL: http://www.w3.org/TR/html4/struct/links.html#h-12.2.3>

As for the rest of your element...

Not sure what you are trying to achieve. If your intention is for
EnableValidators to run onmousedown, then for the script attached to
the href to execute, it does not work in all browsers. Safari (and
maybe others) will not run the script on the href if another function
fires (onclick, onmousedown, etc.).

The usual idea is to have the href go to a useful page for those with
JavaScript disabled, then have the onmousedown end with

return false;

which stops the browser from following the href link if javascript is
enabled.

Then add the script you have on the href to the end of the onmousedown:

<a id="MyDataList__ctl1_edit_Button" NAME="edit_Button"
href="aUsefulPage.html"
OnMousedown="
EnableValidators('editGroup_');
if (typeof(Page_ClientValidate) != 'function' ||
Page_ClientValidate())
__doPostBack('MyDataList$_ctl1$edit_Button','');
return false;
">Edit</a>

The above is utterly untested 'cos I have no idea what all your
functions are, however the syntax should be correct, except I haven't
fixed your invalid id/name combination.

Rob.
 
D

Dufus

RobG said:
From the HTML spec at W3C.org:

"The id and name attributes share the same name space. This means that
they cannot both define an anchor with the same name in the same
document. It is permissible to use both attributes to specify an
element's unique identifier for the following elements: A, APPLET,
FORM, FRAME, IFRAME, IMG, and MAP. *When both attributes are used on a
single element, their values must be identical.*" (my emphasis).

<URL: http://www.w3.org/TR/html4/struct/links.html#h-12.2.3>

As for the rest of your element...

Not sure what you are trying to achieve. If your intention is for
EnableValidators to run onmousedown, then for the script attached to
the href to execute, it does not work in all browsers. Safari (and
maybe others) will not run the script on the href if another function
fires (onclick, onmousedown, etc.).

The usual idea is to have the href go to a useful page for those with
JavaScript disabled, then have the onmousedown end with

return false;

which stops the browser from following the href link if javascript is
enabled.

Then add the script you have on the href to the end of the onmousedown:

<a id="MyDataList__ctl1_edit_Button" NAME="edit_Button"
href="aUsefulPage.html"
OnMousedown="
EnableValidators('editGroup_');
if (typeof(Page_ClientValidate) != 'function' ||
Page_ClientValidate())
__doPostBack('MyDataList$_ctl1$edit_Button','');
return false;
">Edit</a>

The above is utterly untested 'cos I have no idea what all your
functions are, however the syntax should be correct, except I haven't
fixed your invalid id/name combination.

Rob.

Thanks Rob. That was very helpful.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top