title: How can I join two fields of a form into one?
body: <p>I am trying to join a username and a password into one field once I have encoded them into base64. My problem comes when creating a hidden type input, when I send the form, it only sends username and password (both encoded) but it does not join them. The following code is where I have the problem, I think the problem is in the script below the form.</p>
  <p>//Jade file</p>
  <pre><code>extends ./layout.jade 
  block contenido
      div(class=&quot;d-flex justify-content-center center-block big-top-space&quot;)
          form(class=&quot;col-md-6&quot; action=&quot;/user/login&quot; method=&quot;POST&quot; id=&quot;formData&quot; name=&quot;myform&quot;)
              div(class=&quot;form-group&quot;)
                  label(for=&quot;username&quot;) Usuario
                  input(type=&quot;text&quot; name=&quot;username&quot; placeholder=&quot;Usuario&quot; id=&quot;username&quot; class=&quot;form-control&quot;)
              div(class=&quot;form-group&quot;)
                  label(for=&quot;password&quot;) Contraseña
                  input(type=&quot;password&quot; name=&quot;password&quot; placeholder=&quot;Contraseña&quot; id=&quot;password&quot; class=&quot;form-control&quot;)
  
              div(class=&quot;row top-space&quot;)
                  div(class=&quot;col-xs-12 col-sm-6&quot;)
                      input(type=&quot;submit&quot; value=&quot;Iniciar sesión&quot; class=&quot;btn btn-info&quot; onclick=&quot;toBase64()&quot;)
                  div
                      input(type=&quot;hidden&quot; id=&quot;joint&quot;)
                  div(class=&quot;col-xs-12 col-sm-6 text-right&quot;)
                      a(href=&quot;/signup&quot;) No tengo cuenta
  
          script.
              function toBase64(){
  
                  var username = btoa(document.getElementById(&quot;username&quot;).value);
                  var password = btoa(document.getElementById(&quot;password&quot;).value);
  
                  document.getElementById(&quot;joint&quot;).value = username+&quot;:&quot;+password;
  
  
              }
  </code></pre>