0

I have a script for my contact form, which is showing Thnks message and an image after customer pressed "Submit". The thing is that everything is aligned to the right, but I want to center it. Also, it after the customer pressed "Submit" it pushes the next to it div down to the bottom. I will try to post the code and the link to my website. My website

This is the code itself:

//Contact form AJAX form
function _(id) {
  return document.getElementById(id);
}

function submitForm() {
  _("mybtn").disabled = true;
  _("status").innerHTML = 'please wait ...';
  var formdata = new FormData();
  formdata.append("n", _("n").value);
  formdata.append("e", _("e").value);
  formdata.append("p", _("p").value);
  formdata.append("m", _("m").value);
  formdata.append("plans", $('#my_form').find('input[name="plans"]:checked').val());
  var ajax = new XMLHttpRequest();
  ajax.open("POST", "example_parser.php");
  ajax.onreadystatechange = function() {
    if (ajax.readyState == 4 && ajax.status == 200) {
      if (ajax.responseText == "success") {
        _("my_form").innerHTML = '<h2>Thanks ' + _("n").value + '!</h2><p><img src="images/sent.png"></p>';
      } else {
        _("status").innerHTML = ajax.responseText;
        _("mybtn").disabled = false;
      }
    }
  }
  ajax.send(formdata);
}
//END

Btw, I use for styling Bootstrap. Sorry if it is not clear.

Yosvel Quintero
  • 18,669
  • 5
  • 37
  • 46

2 Answers2

0

As the comments suggest this is probably best done with CSS:

This will do the trick:

.contactus {
  text-align: center;
}

If you really want to use jQuery put this somewhere in your document.ready function:

$('.contactus').css('text-align', 'center');
shotor
  • 763
  • 6
  • 17
0

Checked your website contact form, it seems like you just need to add text-align:center; to class .well-sm

<style>
  .well-sm{text-align:center;}
</style> 

This can be achieved with css only.

Mahesh Singh Chouhan
  • 2,558
  • 1
  • 16
  • 26