-3

For example i have a button in a form

<button id="test1 test2" value="test">TEST</button>

For some reason, I want the id "test1" used to get the $_POST value from the button using php and the id "test2" used to catch the onclick event from the user using javascript.

Is this possible or just some uncomfortably question?

Thanks in advance.

8
  • 1
    Not possible, no. You could classes, though. Also, $_POST uses the name attribute. Commented Jul 6, 2015 at 2:59
  • Try maintaining single unique id . Utilize className , or data-* attributes for one of test1 or test2 Commented Jul 6, 2015 at 3:00
  • You can't. http://www.w3schools.com/tags/att_global_id.asp. To store aditional data in tag, refer here: http://www.w3schools.com/tags/att_global_id.asp. Hope this helps. Commented Jul 6, 2015 at 3:00
  • @StuartWagner - Thanks for the correction for the name attribute to get the S_POST data. Commented Jul 6, 2015 at 3:01
  • @guest271314 - Thanks for the information, I've search it and found this one jsfiddle.net/23Qmr/1 I'm working on it now. Commented Jul 6, 2015 at 3:09

1 Answer 1

0

you can have multiple classes and one Id per html page,

A id is meant to identify (distinguish) between elements versus a class combines multiple elements with the same Class

and names don't have to be unique across forms or within forms. The most common use of repeating them is radios:

<form>
    <input type="radio" name="my_radio" value="1">
    <input type="radio" name="my_radio" value="2">
    <input type="radio" name="my_radio" value="3">
</form>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.