Ajax form submit and disable field

Discussion in 'JavaScript' started by promotingspace.net, Apr 23, 2010.

  1. #1
    Hi
    I use ajax to submit my forms. it's working fine
    But the problem is when I disable the submit button onclick, the form is not submitted in IE
    I have made 2 simple forms in 1 html page. if you check that page, ajax submit works on one of them but doesn't work on the one I disable submit field
    It's ok in firefox, both form works in firefox. The problem is in IE
    Here is the page:
    http://khojasteh.org/project/test/

    And this is the source code for 2 forms:
    
    <head>
    <script src="http://khojasteh.org/project/test/ajaxsbmt.js" type="text/javascript"></script>
    
    <title>Ninja Looters </title>
     <link href="style/style.css" rel="stylesheet" type="text/css" />
    <link rel="STYLESHEET" type="text/css" href="template_files/main.css">
    
    </head>
    <table width=60% align=left>
    <tr>
    <td colspan=3> 
    Ajax submit doesn't work here
    </td></tr>
    <br>
    <form name="form2" method="post" onsubmit="xmlhttpPost('ajaxphp.php', 'form2', 'char_result1', '<img src=\'images/pleasewait.gif\'>'); return false;">
    <input type=hidden name="action" value="importcharacter">
    
    <tr>
    <td>   Name: </td><td colspan=2>  <input type="text" name="name" size=30/>  </td>
    </tr>
    <tr>
    <td>  &nbsp; </td><td colspan=2> <input type="submit" name="Submitbtn" value="Submit" id="Submitbtn" onclick="Disablefield(Submitbtn)">  </td>
    </tr>
    <tr><td colspan=3> <div id="char_result1"></div>
    </form>
    
    
    <form name="form1" method="post" onsubmit="xmlhttpPost('ajaxphp.php', 'form1', 'char_result2', '<img src=\'images/pleasewait.gif\'>'); return false;">
    <input type=hidden name="action" value="importcharacter">
    <tr><td colspan=3> &nbsp;</td></tr>
    <tr>
    <td colspan=3> Ajax submit works here </td></tr>
    <tr>
    <td>   Name: </td><td colspan=2>  <input type="text" name="name" size=30/>  </td>
    </tr>
    <tr>
    <td>  &nbsp; </td><td colspan=2> <input type="submit" name="Submitbtn2" value="Submit" id="Submitbtn2" >  </td>
    </tr>
    </form>
    <tr>
    <td colspan=3> <div id="char_result2"></div></td></tr>
    </table>
    HTML:

     
    promotingspace.net, Apr 23, 2010 IP
  2. zerophean

    zerophean Peon

    Messages:
    91
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Change this script

    From :
    
    <form name="form2" method="post" onsubmit="xmlhttpPost('ajaxphp.php', 'form2', 'char_result1', '<img src=\'images/pleasewait.gif\'>'); return false;">
    
    and
    
    <input type="submit" name="Submitbtn" value="Submit" id="Submitbtn" onclick="Disablefield(Submitbtn)">
    
    HTML:
    To :

    
    <form name="form2" method="post" onsubmit="Disablefield(Submitbtn);xmlhttpPost('ajaxphp.php', 'form2', 'char_result1', '<img src=\'images/pleasewait.gif\'>'); return false;">
    
    and
    
    <input type="submit" name="Submitbtn" value="Submit" id="Submitbtn">
    
    HTML:
     
    zerophean, May 1, 2010 IP
  3. promotingspace.net

    promotingspace.net Peon

    Messages:
    361
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks
    Is there a way to disable all form fields in 1 click? or I have to disable all fields 1 by 1?
     
    promotingspace.net, May 1, 2010 IP