Skip to content

Counter: Counter Powered by  RedCounter Categories:

Hilangkan koma awal dan ahir

Berikut ini adalah contoh script remove comma  awal dan ahir pada js, misal var val = “,A,B,C,D,E,F,”; akan di hilangkan koma awal dan ahirnya dengan menggunakan script js sehingga hasil yang di inginkan adalah var val = “A,B,C,D,E,F”;.

<script language=”javascript>
function removeComma()
{
var val = “,A,B,C,D,E,F,”;
val = val.split(”,”);
var removecomma=[];
for(k=0; k < val.length ;k++){
if(val[k]!=”"){
removecomma.push(val[k]);
}
}
var finish = removecomma.join(’,');
alert(finish);
}
</script>
<input type=”buttonname=”aid=”aonclick=”removeComma()value=”view/>

hasil yang bisa dilihat saat button di click

remove-comma

Posted in JS.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.