jquery - copy Multiple values from multiple input fields into one input field using javascript? -


i trying find way copy value of multiple input fields 1 single input field.

currently can copy 1 input field 1 using following code:

addevent(document.getelementbyid('inputname'), 'keyup', function () {    document.getelementbyid('inputurl').value = this.value.replace(' ', ' ');  $(".sect2 input[@value='']").parents(".sectxt").hide(); });   function addevent(ele, evnt, funct) {   if (ele.addeventlistener) // w3c     return ele.addeventlistener(evnt,funct,false);   else if (ele.attachevent)  // ie     return ele.attachevent("on"+evnt,funct); } 

is possible this:

addevent(document.getelementbyid('inputname, inputname2, inputname3, inputname4'), 'keyup', function () {    document.getelementbyid('inputurl').value = this.value.replace(' ', ' ');  $(".sect2 input[@value='']").parents(".sectxt").hide(); });   function addevent(ele, evnt, funct) {   if (ele.addeventlistener) // w3c     return ele.addeventlistener(evnt,funct,false);   else if (ele.attachevent)  // ie     return ele.attachevent("on"+evnt,funct); } 

if not, correct way of doing this?

thanks in advance.

update:

none of examples bellow works , neither practical.

i tried own solution , didn't work either.

i can assume not possible using javascript!

your second example isn't possible, if you're using jquery anyway simplest solution

update - having thought this, want below

$(function(){    $('#inputname, #inputname2, #inputname3, #inputname4').keyup(function(){            var str = "";        $('#inputname, #inputname2, #inputname3, #inputname4').each(function() {            str += $(this).val().replace(' ', '');        });        $('#inputurl').val(str);    }); }); 

i've added jsfiddle here of working example


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -