2
I have a field that when it is filled it makes several triggers, beauty so far, everything well achieved with the code below.
$("#teste").change(function () {
var valor = $(this).val();
$("#nome").val(valor);
$("#idade").val(valor);
});
The problem is that my field comes with an example information, maicon/29
, name and age as I do in jQuery to get all the information up to the bar and also get all the information after the bar, as I do this? And if I have another bar, how to treat it?
post your html so we can see
– user28266
Will the information always be name/age? Or can you have more information? name/age/city/state? You can try using a split
valor.split('/')
, will return an array with all the information. Post your HTML to get a better idea of how to respond.– cbonomini
@cbonimini , I guess you didn’t read the question right. (with do this and if I have another bar how to treat it.)
– Marco Souza
@If Maicon has more than one bar, how should it look? "banana/potato/35" should be "banana/potato" the name, and 35 age? I put a bold at the end of your question, so you don’t forget that point in the answer, but it would be good if you [Edit] and add input examples with extra bars, and how you want the output in these cases.
– Bacco