mts9
asked on
Lost History On Window.History.Back() -- Javascript and ColdFusion
Hello All,
I have a basic ColdFusion form with input boxes and combo boxes. The combo boxes are populated by CF queries. After submittal of the form, I do some server side error checking on the action page. If an error occurs, I display the error to the user and provide a link (simply window.history.back()) for him or her to return to the form to correct data. Sounds simple right? Well, here is where the complication comes in...at least for me anyhow. One of the combo boxes has an "OnChange" event that causes other fields to be populated. If I don't select anything from that combo box and force the error, the history is retained, but if something is selected from that combo box and an error occurs, the history disappears. Not only the combo box info is gone, but all the other information that I filled in as well...just sends me back to a blank form. Any help would be appreciated!
The code is pretty simple on the action page...just the CF validation and the window.history.back(); link. Below is the combo box.
<cfquery name="QRY_JOB_TYPES" atasource="#LAP_DATA_SOURC E#">
SELECT JOB_TYPE_DESC, DEFAULT_DAYS
FROM tab_JOB_TYPES
ORDER BY JOB_TYPE_DESC
</cfquery>
<select name="cmb_Type" size="1" onchange="Javascript:PopDa tes()">
<option value="" selected>
<cfloop query="QRY_JOB_TYPES">
<option value="#QRY_JOB_TYPES.JOB_ TYPE_DESC# "><font class="ArialBlk8">#QRY_JOB _TYPES.JOB _TYPE_DESC # (average completion in #QRY_JOB_TYPES.DEFAULT_DAY S# days)</font>
</cfloop>
</select>
<script language="JavaScript">
function PopDates()
<!--- Opens a popup that displays a please wait message and populates estimated start and end dates based on the job type selected --->
{
var typeindex = document.frm_JOB_ADD.cmb_T ype.select edIndex;
var selectedtype = document.frm_JOB_ADD.cmb_T ype.option s[typeinde x].value;
var mypath = "JOB_POPULATE_DEFAULT_DATE S_AND_USER .cfm?URL_T YPE=" + escape(selectedtype) + "&URL_BEG_DATE=" + escape(document.frm_JOB_AD D.txt_EST_ START_DATE .value);
window.open(mypath+"&rando m="+Math.r andom(),"m ywin","scr ollbars=1, left=190,t op=160,wid th=160,hei ght=80"); <!--- Opens Page And Refreshes Info From Server --->
}
</script>
Thanks!
I have a basic ColdFusion form with input boxes and combo boxes. The combo boxes are populated by CF queries. After submittal of the form, I do some server side error checking on the action page. If an error occurs, I display the error to the user and provide a link (simply window.history.back()) for him or her to return to the form to correct data. Sounds simple right? Well, here is where the complication comes in...at least for me anyhow. One of the combo boxes has an "OnChange" event that causes other fields to be populated. If I don't select anything from that combo box and force the error, the history is retained, but if something is selected from that combo box and an error occurs, the history disappears. Not only the combo box info is gone, but all the other information that I filled in as well...just sends me back to a blank form. Any help would be appreciated!
The code is pretty simple on the action page...just the CF validation and the window.history.back(); link. Below is the combo box.
<cfquery name="QRY_JOB_TYPES" atasource="#LAP_DATA_SOURC
SELECT JOB_TYPE_DESC, DEFAULT_DAYS
FROM tab_JOB_TYPES
ORDER BY JOB_TYPE_DESC
</cfquery>
<select name="cmb_Type" size="1" onchange="Javascript:PopDa
<option value="" selected>
<cfloop query="QRY_JOB_TYPES">
<option value="#QRY_JOB_TYPES.JOB_
</cfloop>
</select>
<script language="JavaScript">
function PopDates()
<!--- Opens a popup that displays a please wait message and populates estimated start and end dates based on the job type selected --->
{
var typeindex = document.frm_JOB_ADD.cmb_T
var selectedtype = document.frm_JOB_ADD.cmb_T
var mypath = "JOB_POPULATE_DEFAULT_DATE
window.open(mypath+"&rando
}
</script>
Thanks!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
All,
Yes, I agree both of these fixes, but I guess I was looking for why my problem is occurring.
Thanks
Mike
Yes, I agree both of these fixes, but I guess I was looking for why my problem is occurring.
Thanks
Mike
Because you are not providing any way to maintain persistance of the user's inputs.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Points for both...thanks
glad i could help
thanks for the points!
thanks for the points!
try some client side validation too
<form action="' method="" onSubmit="return validateForm(this);">
<script>
function validateForm(objForm){
var strErr="";
var objFocus="";
if (!objForm.formElement.valu
strErr+="FormElement is blank!\nThis is a required field.")
if(!objFocus){
objFocus=objForm.formEleme
}
..do all validation
if(strErr){
alert(strErr);
objFocus.focus();
}
return !strErr;
}
}
}