Jump to content

[SOLVED] Reinsert Ajax Data After Form Submit


fanfavorite

Recommended Posts

I create forms using PHP and use AJAX to add fields that are relevant and remove fields that aren't relevant as the user fills out the form.  All works well with that.  Now once the user hits submit, I reload the page to check for any missing information, etc.  Again, all is fine to this point.  However when there is missing information, I want the form to come up as it was just before the submit.  This is where I have the problem.  If I don't do anything, it will not show any of the updated AJAX information.  Now I thought about that and thought that maybe if I do the javascript calls based on the POST variable values, I could make it how it was, but there are some errors.  Heres the code:

 

<form enctype="multipart/form-data" id="orderform" name="orderform" action="" method="post">
<div class="formsleft">Answer Yes/No</div>
             <div class="formsright">
                             <select name="yesnofield" onchange="showField(this.value,'havesite2')">
		<option value="No"<? if ($_POST['website'] == "No") { echo ' selected="selected"'; } ?>>No</option>
		<option value="Yes"<? if ($_POST['website'] == "Yes") { echo ' selected="selected"'; } ?>>Yes</option>
	   </select>
	   <script type="text/javascript">
	   <!--
	   showField('<? echo $_POST[yesnofield]; ?>','havesite2');
              	   showField('<? echo $_POST[transfertoats] ?>','transfertous')
	   -->
	   </script>
</div>
<div id="havesite2"></div>
<div id="transfertous"></div>
<input type="submit" alt="Submit" name="submit" id="submit" value=" " class="formsubmit" />
</form>	

 

Now the "yesnofield" populates the havesite2 and "transfertoats" is a yes/no field inside havesite2.  This particular code in Firefox, will update fine if I put either showField call separately, but if they are together, the second one seems to override the first one depending on how fast the first one is.  For example, sometimes when it loads it will show part of what is supposed to be in havesite2, with the transfertous script in both havesite2 and transfertous.

 

Any help on this issue would be appreciated. 

 

Thanks,

 

-JC

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.