I'm trying to combine mulitple inputs then combine them to form a sentence/phrase. This example will elaborate it more.
INPUT1: Happy
INPUT2: Birthday to you
INPUT4: You belong to the zoo
INPUT5: and the monkey and the donkey
INPUT6: The Gorilla is you
Output:
Happy, Birthday to you, You belong to the zoo, and the monkey and the donkey, The Gorilla is you
Expected Output:
Happy Birthday to you, You belong to the zoo, and the monkey and the donkey, The Gorilla is you
I want to set a condition where in INPUT one will not be joined using comma(,) rather just a space. How can I accomplish this? Here's a fiddle and code. Appreciate all the help thnx
Fiddle: http://jsfiddle.net/hztMj/6/
Code:
<input class="combine" id="input1" disabled="true" value="Happy"></input>
<input class="combine" id="input2" disabled="true" value="Birthday to you"></input>
<input class="combine" id="input3" disabled="true" value="You belong to the zoo"></input>
<input class="combine" id="input4" disabled="true" value="and the monkey and the donkey"></input>
<input class="combine" id="input5" disabled="true" value="The Gorilla is you"></input>
<input class="combine" id="Voltes5" disabled="true" size="75"></input>
<button id="LaserSword">Set</button>
JS
$(document).ready(function () {
$('#LaserSword').on('click', function () {
var form = $('.combine').not('#Voltes5');
var val = form.map(function () {
var value = $.trim(this.value)
return value ? value : undefined;
}).get();
$('#Voltes5').val(val.join(', '))//part to be improved
});
});