vendredi 24 juin 2016

How to pass data to input through label?

This is really something I couldn't find anywhere. Or, maybe a different solution for it, but I can't really figure it out.

Let's say I have a <label for='example'>X</label>

Now, that I have a <input id='example' value='//resultfromdb//' type='submit' />

Note that type=submit here

The problem is, that I have to store a value in each "input", and by input here I mean label, that is pulled out from database. But binding a label to a input with the same ID won't work as expected. There is only one input, but has to change it's value through form submission regarding to label My expectation is something like

<label for='example' value='//resultfromdb//'></label>...

This didn't work obviously... Any suggestions?

UPDATE:

There is x amount of labels pulled out from DB, but they must have a different value "Stored" in "themselves", but they are binded to only one input. The input will get the value of label when clicked on the label containing a value. Example:

<label for='example' value='1'></label>
<label for='example' value='2'></label>
<label for='example' value='3'></label>
<label for='example' value='4'></label>
<label for='example' value='5'></label>
<label for='example' value='6'></label>

<input type='submit' id='example' value='**the label value**' />

Aucun commentaire:

Enregistrer un commentaire