Hi,
Can an custom attribute be added into a input tag, apart from the predefined one
<td ><button type="button" title="title" onclick="myFunc tion()" name="Name" ><span>OK</span></button></td>
my button is as above is there any way that i can include another custom attribute to this.
in advance......
Thanks for your reply
5 10569
Hi,
Can an custom attribute be added into a input tag, apart from the predefined one
<td ><button type="button" title="title" onclick="myFunc tion()" name="Name" ><span>OK</span></button></td>
my button is as above is there any way that i can include another custom attribute to this.
in advance......
Thanks for your reply
Yes why not?
Of course u can.
Look at this code carefully ... -
//All the elements r in document .... object reference.Right?
-
var obj_ref = new Object();
-
obj_ref.custom_attr = ur_some_value; //Right?
-
alert(obj_ref.custom_attr); //It ll not return undefined.Right?
-
Have a good day.
Kind regards,
Dmjpro.
gits 5,390
Recognized Expert Moderator Expert
yep ... you may add custom-attributes, and in my opinion it is the best way to do a lot of things where you have to have more then an id or name or other standard-attribs for an element. of course your may misuse other (standard) attributes ... class is a real good candidate for this ... and you may build some combined attribute-values that you use later on ... something like that: -
// part1 ... to 3 is used later on seperately
-
<tagname ... class="part1_part2_part3"/>
-
but as the example shows, i think this will break the semantics of your code ... until you really need 3 attributes for the element you shouldn't be forced to combine them and set it as one value to an attribute, that has an other purpose.
But! there is a drawback of using custom attributes ... they make your (x)html invalid ... when checking against a DTD or XML-schema ... and may be your attributes may interfere with future versions of HTML-implementations ... so use attr-names that are not common ... Browsers don't bother about custom attributes even when the page is invalid ... it has to be wellformed ... and validity is an add-on ... and as i said ... i always would prefer the custom-attr-way instead of misusing standard-attributes
kind regards ...
yep ... you may add custom-attributes, and in my opinion it is the best way to do a lot of things where you have to have more then an id or name or other standard-attribs for an element. of course your may misuse other (standard) attributes ... class is a real good candidate for this ... and you may build some combined attribute-values that you use later on ... something like that: -
// part1 ... to 3 is used later on seperately
-
<tagname ... class="part1_part2_part3"/>
-
but as the example shows, i think this will break the semantics of your code ... until you really need 3 attributes for the element you shouldn't be forced to combine them and set it as one value to an attribute, that has an other purpose.
But! there is a drawback of using custom attributes ... they make your (x)html invalid ... when checking against a DTD or XML-schema ... and may be your attributes may interfere with future versions of HTML-implementations ... so use attr-names that are not common ... Browsers don't bother about custom attributes even when the page is invalid ... it has to be wellformed ... and validity is an add-on ... and as i said ... i always would prefer the custom-attr-way instead of misusing standard-attributes
kind regards ...
Thaks for the reply .....
Finally i got it working
hi,
below is my button
<td><button type="button" custom="custom" title="title" onclick = "myFunction()"> </button></td>
in javascript on click
i say
if(custom){aler t("Got IT !!!")}
This works well with IE but not with firefox.
Thaks for the reply in advance.
acoder 16,027
Recognized Expert Moderator MVP
Merged threads because they were on the same topic.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: F. Da Costa |
last post by:
Hi,
I was wondering *why* there is a difference between the results of the
following two statements. On the suface they seem to do the same (or do they?)
frm => returns void
frm.getAttribute("custom") => returns the value of the attribute
|
by: Edward Diener |
last post by:
I understand the syntax of custom attributes, but I have no idea what they
are supposed to do. Anyone care to give me a clue as to their functionality
?
|
by: One Handed Man \( OHM - Terry Burns \) |
last post by:
When using a custom control. In order to check and see if values have
changed one has to implement the IPostBackDataCollection interface. The
values returned for the control seem to be simply a string with comma
delimited values.
For example, if I were to render two text boxes. One with the Value Terry
and the Other with the Value 'Burns' I would get the following value
Terry,Burns.
|
by: Chris Newby |
last post by:
I have a custom control that derives from the WebControls.Panel class.
In a given ASPX document, I have an instance of my custom control with ID
set to "MyControl".
Then I put a WebControls.TextBox control inside my custom control with ID
set to "MyTextBox".
When this page renderes, inspection of the HTML source shows that the Name
attribute of the input tag generated from MyTextBox is now actually
|
by: The Developer |
last post by:
Hi All,
I have a web application where I am adding a custom attribute to my ASP.NET
text box control and changing value of that attribute at client side using
JavaScript. My problem is that changed value of that custom attribute is not
reflecting back at server side. Any ideas about this problem?
Server side code:
private void Page_Load(object sender, EventArgs e)
{
if (this.IsPostBack == false)
| |
by: Mark R. Dawson |
last post by:
Hi all,
I am trying to get custom attributes from a property. I can do this if I
pass in the name of the property i.e. "Name" to the reflection methods, but
if I pass in set_Name which is what the set piece of the Name property gets
compiled to, which I am getting from the stack trace, then the attributes are
not returned.
For example, Class Person has a property called "Name" which has a custom
attribute decorating it. Inside the set...
|
by: prabhupr |
last post by:
Hi Folks
I was reading this article
(http://www.dotnetbips.com/articles/displayarticle.aspx?id=32) on
"Custom Attribute", written by Bipin.
The only thing I did not understand in this article is the usage of
"Custom Attribute" in real life project. Can somebody please help me
understand where are these informations really helpful in Development
Environment; may be a few example(s) will help me understand.
|
by: webmaster |
last post by:
Hi all,
I'm tearing my hair out with this one.
I have successfully implemented by own RadioButtonList in order to
provide additional functionality and a DIV rather than TABLE-based
layout in one of my ASP.NET 1.1 web forms. This involves a fairly
simple inheritance of the System.Web.UI.WebControls.RadioButtonList
class, with some new properties added and the Render sub overridden.
When I come to render each radio item, I do the...
|
by: P4trykx |
last post by:
Hello
I'm want to add some custom attributes to WebControls using
WebControl.Attributes.Add("abc","234");
So the html output will look like this,
<input type="hidden" abc="123" /etc.
I know that I need to modify .dtd file and tell the browser that abc i
legal attribute.
But I have another problem, I can't change the abc attribute using
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |