8

Is it possible to explode datas in array according to a charachter?

.each(myArr, function(key, value) { 

});

i take array like that

value is the values of array . Can explode value with "-" ?

1

4 Answers 4

24

Use split():

var items = value.split('-');
Sign up to request clarification or add additional context in comments.

Comments

8

You can use split

 var arr = str.split('-');

Comments

4

Yes, you use value.split('-');

Comments

1

you can write like this

function add_nik(id)
{
    $('#modal_form').modal('hide'); // show bootstrap modal
    var hasil=id.split(',');
    $('#nik').val(hasil[0]);
    $('#nama').val(hasil[1]);
}

in yout html code

<input type="text" name="nama" id="nama" >
<input type="text" name="nik" id="nik>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.