Sam Roberts
Sam Roberts

Reputation: 399

Is there a way to have multiple data-paramname and data-paramvalue in javascript?

In my code I have:

    <input type=button data-paramname="firstname" data-paramvalue="Joe" data-paramname="lastname" data-paramvalue="Smith" value="Test Button">

But the 2nd data-paramname is ignored, and when I inspect the element in the browser it only sees:

<input type=button data-paramname="firstname" data-paramvalue="Joe" value="Test Button">

What is the best work around for this, to have 2 params for a particular button?

Upvotes: 0

Views: 65

Answers (1)

garryp
garryp

Reputation: 5776

No attributes should not be duplicated. This is poor practice and even if it does work in some browsers you will probably have issues in others. Either use different attributes or put the values in the same attribute and comma delimit them.

Upvotes: 2

Related Questions