javascript form help

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Apr 2007
Posts: 33
Reputation: realnsleo is an unknown quantity at this point 
Solved Threads: 0
realnsleo realnsleo is offline Offline
Light Poster

javascript form help

 
0
  #1
Nov 13th, 2008
hi there,
i have a problem resetting my form with javascript. I have a registration form that when submitted, the action is performed in an iframe so that the browser does not have to load another page. After form validation, i want the php script in the iframe to clear all fields of the form in the parent document. i have tried all ways like:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. $insert_sql = mysql_query("INSERT INTO ...... ");
  2. if($insert_sql){
  3. ?>
  4. <script>
  5. alert("Query Successful");
  6. parent.document.forms[0].reset();
  7. </script>
  8. <?php
  9. }else{
  10. ?>
  11. <script>
  12. alert("<?php mysql_error($conn); ?>");
  13. </script>
  14. <?php
  15. }

i have tried everything from giving the form an ID and using
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. document.getElementById('form').reset();
But i still cannot reset the form. What can i do. Please help. Thanks alot.
baba
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 167
Reputation: Drew is an unknown quantity at this point 
Solved Threads: 7
Drew's Avatar
Drew Drew is offline Offline
Junior Poster

Re: javascript form help

 
0
  #2
Nov 19th, 2008
Are you getting any javascript errors?
Drew Gauderman
ASP / MSSQL Coder
http://www.iportalx.net - My ASP Portal
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 24
Reputation: sasankasekhar is an unknown quantity at this point 
Solved Threads: 3
sasankasekhar's Avatar
sasankasekhar sasankasekhar is offline Offline
Newbie Poster

Re: javascript form help

 
0
  #3
Nov 22nd, 2008
Originally Posted by realnsleo View Post
hi there,
i have a problem resetting my form with javascript. I have a registration form that when submitted, the action is performed in an iframe so that the browser does not have to load another page. After form validation, i want the php script in the iframe to clear all fields of the form in the parent document. i have tried all ways like:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. $insert_sql = mysql_query("INSERT INTO ...... ");
  2. if($insert_sql){
  3. ?>
  4. <script>
  5. alert("Query Successful");
  6. parent.document.forms[0].reset();
  7. </script>
  8. <?php
  9. }else{
  10. ?>
  11. <script>
  12. alert("<?php mysql_error($conn); ?>");
  13. </script>
  14. <?php
  15. }

i have tried everything from giving the form an ID and using
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. document.getElementById('form').reset();
But i still cannot reset the form. What can i do. Please help. Thanks alot.

Its difficult to figure out the problem without viewing the code of the while form.
Just a guess:
May be in the your fields have been assigned value after the form reset.
for example
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. $insert_sql = mysql_query("INSERT INTO ...... ");
  2. if($insert_sql){
  3. ?>
  4. <script>
  5. alert("Query Successful");
  6. parent.document.forms[0].reset(); //here you are resetting the form
  7. ........................
  8. ........................
  9. </script>
  10. <?php
  11. }
  12. <form action=...>
  13. <input name="appName" value = "<?php echo $appName; ?>" > <!-- here again values are assigned -->

I guess this may be the problem ... because the code in the page is normally processed top to bottom .. the form has been reset but the values are again assigned.

If it doesnot solve your problem, please provide the whole code.
Regards ...
IF SOMEONE FEELS THAT THEY HAD NEVER MADE A MISTAKE IN THEIR LIFE, THEN  IT MEANS THEY HAD NEVER TRIED A NEW THING IN THEIR LIFE
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC