Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    I did ... one post ago ... you indeed have an XHTML doctype that's why document.forms["name"] will not work, but document.getElementById("formid") will as soon as your form element has the id="formid"

  2. #17
    New Coder
    Join Date
    Aug 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Still failed to get the expected post submission action. Used the following code.

    document.getElementById('form'+count_number).submit();

    In form tried with both :


    <form name="form<?php echo $j?>" id="form<?php echo $j?>" action="<?php echo $_SERVER['PHP_SELF']?>" method="post" onsubmit="contract(<?php echo $j?>);return false;">



    <form name="form<?php echo $j?>" id="form<?php echo $j?>" action="#" method="post" onsubmit="contract(<?php echo $j?>);return false;">
    Last edited by dev07; 08-04-2011 at 09:21 AM.

  3. #18
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    Ok, now I see the next flaw ... you should remove the onsubmit from the form and move it as onclick to the submit button

    Otherwise you will always end up in running contract() again as soon as the form is being submitted programmatically.

  4. #19
    New Coder
    Join Date
    Aug 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, i removed the onsubmit action from form tag. Added onclick function on submit button. But, i am having the following problems.

    CASE 1) While using the code

    <input type="submit" name="btn_submit" style="background: url(accept.jpg) no-repeat scroll center center transparent; cursor: pointer; border: 0pt none; width: 88px; height: 23px;" value="" onclick="contract(<?php echo $j?>);">

    AND

    if(parseInt(response, 10)==1)
    {
    if(confirm('Please confirm that this is a binding contract'))
    { document.getElementById('accept_offer'+count_number).submit();
    }

    }
    else {
    alert("Sorry, you are a little late. ");
    }



    ==> The form always returns true and gets submitted and does post submission task without displaying the confirm message or alert message.



    CASE 2) While using the code

    <input type="submit" name="btn_submit" style="background: url(accept.jpg) no-repeat scroll center center transparent; cursor: pointer; border: 0pt none; width: 88px; height: 23px;" value="" onclick="contract(<?php echo $j?>);return false;">

    AND

    if(parseInt(response, 10)==1)
    {
    if(confirm('Please confirm that this is a binding contract'))
    { document.getElementById('accept_offer'+count_number).submit();
    }

    }
    else {
    alert("Sorry, you are a little late. ");
    }


    ==>The form does not submits its data and also post submission task does not executes.


    CASE 3) Removed return false from submit button and tried to use inside javascript condition [i.e return true if confirm else return false], but it returns the result of CASE 1.

  5. #20
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    CASE 2 should be the correct one ... you should continue from there and debug

    1. Is the function actually being called?
    2. Does it start the Ajax request
    3. Does the Ajax request return with the correct result
    4. Does the confirm() come up
    5. Finally: Does the .submit() actually do anything?

    Right now, obviously it doesn't reach step 5 ... but you can only find out through debugging

  6. #21
    New Coder
    Join Date
    Aug 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by devnull69 View Post
    CASE 2 should be the correct one ... you should continue from there and debug

    1. Is the function actually being called?
    2. Does it start the Ajax request
    3. Does the Ajax request return with the correct result
    4. Does the confirm() come up
    5. Finally: Does the .submit() actually do anything?

    Right now, obviously it doesn't reach step 5 ... but you can only find out through debugging

    Answers to your questions.

    1) Yes, the function has been called.

    2) Ajax request started and getting correct result from AJAX request.

    3) Confirm message is coming up.

    4) Then if i press "OK", the page gets refreshed but no post submission task executes. If i press "Cancel", nothing happens.


    I tried to debug and found the followings.

    1) In a normal submission process [without using return false in onclick] the form gets submitted. And the url is:

    http://abc.com/abc.php?InterestedUse...=&btn_submit=#


    2) While using return false in onclick and after confirming "ok" , i found the following url

    http://abc.com/abc.php?InterestedUse...=172&ItemId31=

    where btn_submit= is missing.


    I am processing the post submission query using the following code:


    if(isset($_REQUEST['btn_submit']))
    {
    ...
    ...
    }


    Now, as $_REQUEST['btn_submit'] is absent in the url, the page does not process post submission task.

    I tried to modify the document.getElementById('accept_offer'+count_number).submit(); by document.getElementById('btn_submit').click(); but did not succeed. This time , the confirm message comes out whenever i am clicking on "OK".
    Last edited by dev07; 08-05-2011 at 09:32 AM.

  7. #22
    New Coder
    Join Date
    Aug 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I got a solution but not sure whether i should use this or not.


    1) I have added another submit button and made it hidden.

    <input type="submit" name="Btn_Submit" id="Btn_Submit" style="background: url(accept.jpg) no-repeat scroll center center transparent; cursor: pointer; border: 0pt none; width: 88px; height: 23px;" value="" onclick="contract(<?php echo $j?>);return false;">

    <input style="display:none" type="submit" name="btn_submit" id="btn_submit<?php echo $j;?>"></input>



    2) Now on javascript function using this code.

    if(confirm('Please confirm that this is a binding contract'))
    { document.getElementById('btn_submit'+count_number).click();
    }



    Using this i can perform the post submission task in Firefox. I will test other browser as well.

    Please give me your suggestion.


 
Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •