3

On form submission does anything else get submitted but the value? Can I submit the value and the data-group attribute?

 <input type="text" id="theInput" data-group="5" value="the value" />

I'm just talking about a PHP form submission

Phill Pafford
  • 83,471
  • 91
  • 263
  • 383
  • You can either create some hidden inputs (input type="hidden"), as their values will be sent, or use JS; don't see the other way around. – raina77ow Feb 25 '12 at 03:51

1 Answers1

5

Only the value gets submitted, but you can add a hidden element for the data-group value. Also note that you should use a name attribute to identify the parameter key:

<input type="text" id="theInput" name="theInput" data-group="5" value="the value" />
<input type="hidden" name="theInputGroup" value="5" />

This will come back to the server with the request parameters of:

  • theInputthe value
  • theInputGroup5

Sidenote: If you are submitting the form via ajax, you can just add the group directly into the parameter list instead of adding a hidden input.

Ben Lee
  • 52,489
  • 13
  • 125
  • 145
  • I can't find mention of a `data-group` property on the web. Where is it documented? (Sorry Ben, not you - it appears in the question) – Beetroot-Beetroot Feb 25 '12 at 03:58
  • 1
    @Beetroot-Beetroot, `data-group` is a custom HTML5-standard `data-*` attribute. See http://html5doctor.com/html5-custom-data-attributes/ – Ben Lee Feb 25 '12 at 04:04
  • That's what I had thought but wanted to know if HTML5 other options might be available – Phill Pafford Feb 25 '12 at 04:09