mercredi 24 juillet 2019

Change character used for separation of form input fields with same name identifier?

I have a form which has a bunch of checkboxes like this:

<input type="checkbox" name="input1" value="A, and B"/>A, and B
<input type="checkbox" name="input1" value="C"/>C

I also have some JQuery code that populates the already selected fields using JSTL like this:

$('input[name="input1"]').val("${form_inputs}".split(','));

The thing is since the value "A, and B" contains a comma, the jquery is splitting and setting the checkbox checked states wrong.

I already tried adding more commas so I could split at ",," but it doesnt seem to want to work.

Is there any way to change the comma splitter character to a different character?




Aucun commentaire:

Enregistrer un commentaire