Javascript "implode" alternative to PHP "implode"


<form action="form.php" method="get">
<div class=""><input name="field" value="1" type="checkbox"> Option One </div>
<div class=""><input name="field" value="2" type="checkbox"> Option Two </div>
<div class=""><input name="field" value="3" type="checkbox"> Option Three </div>
<input class="fsubmit" src="images/buttons/find.gif" value="Show Threads" type="submit">

Here is the equation. The form above appends field values to the URL that looks like:

What I’m trying to achieve is something like:,2,3

Would someone suggest a way to do that? Not sure if that’s got to be a javascript way of doing it, just guessing.


In JavaScript Array values can be imploded together into a single string with the ‘join’ method of the Array Object

<script type="text/javascript">
    var testArray = new Array();
    testArray[0] = 'first';
    testArray[1] = 'second';
    testArray[2] = 'third';
    alert(testArray.join(',')); // returns the string  'first,second,third'

For more details, check this reference.

Thanks, Kailash.