1

I have this piece of code here

<script>
function req() {
  $("div.formbut").hide("slow");  
  $("div.inqform").show("slow");  
var targetOffset = $(\'div.inqform\').offset().top; $(\'html,body\').animate({scrollTop: targetOffset}, 1000);   
  }
$("submit2").click(req);
$("form").submit(function () {
  if ($("input").val() == "yes") {
    $("p").show(4000, function () {
      $(this).text("Ok, loaded! (now showing)");
   });
  }
  $("div.rates").hide("slow");
  $("div.ratesbut").hide("slow");  
  $("div.inqform").hide("slow");
  $("div.done").show("slow");
var targetOffset = $(\'div.done\').offset().top; $(\'html,body\').animate({scrollTop: targetOffset}, 1000);     
  return false; 
});
</script>

the "div.inqform" has a small form in it. I noticed that it does not get posted. How can I get the form submitted without ruining what I have already ?

Thanks in advance.

2
  • I don't see any ajax request code in what you have posted.
    – Sarfraz
    Commented Jan 15, 2011 at 13:03
  • Why do you have \' in your code? That is invalid JS. Commented Jan 15, 2011 at 13:03

2 Answers 2

1

Whats the mistake you are making over here I think is

$("submit2").click(req);  // change this to $("#submit2").click(req);
$("form").submit(function () { // change this to $("#form").submit(function () {

you have to use $("#submit2") for id="submit2"

and you have to use $(".submit2") for class="submit2"

Also remove \' from your code and try

0

Well it looks like you are using Prototype. There is a form.request method available that you acn use to submit a form over ajax and get the response text.

Your form however looks to beloaded via ajax and then inserted into the dom. So you may run into some troubles that have been dealed with here. You can also get the codes necessary from this question and answer:

Can't access Elements previously created by innerHTML with Javascript/Prototype

Not the answer you're looking for? Browse other questions tagged or ask your own question.