I have a form in a coldfusion page. After hitting save button which is inserting into a table, I need to reload the page with the new values of the table in a select box. Though the page is refreshing after submit, I am not able to see the new inserted value in the drop down. Only after manually refreshing the page I can see it. I have the below code
<script>
function confirm_insert()
{
var ok = confirm("Are you sure you want to save the changes?");
if (ok)
{
document.myform.submit();
return true;
}
else
{
return false;
}
}
</script>
<form name="myform" action="bsc_lookup_number_add.cfm" method="post" >
<td><input type="text" <cfif isDefined('page.select_Main_Group')>value="#page.select_Main_Group#"</cfif>></td>
<td><input type="text" <cfif isDefined('page.select_Sub_Group')>value="#page.select_Sub_Group#"</cfif>></td>
<td><input name="newfirstchars" type="text" value="" maxlength="3"></td>
<input type="submit" class="button" name="saverecord" id="saverecord" style="width:100px" value="Save Record" onClick="return confirm_insert();">
<cfquery name="first3" datasource="mbtran">
select * from (
select cast((substr(A.LABORLEVELNAME2, 1, 3)) as varchar2(5 byte)) first_3_pos
from tkcsowner.VP_LABORACCOUNT a
<cfif isDefined('page.select_Sub_Group')>
where substr(A.LABORLEVELNAME1, 1, 5) || substr(A.LABORLEVELNAME2, 4, 2) = ('#page.select_Main_Group#' || '#page.select_Sub_Group#')
</cfif>
union
select A.FIRST_3_CHARS_IN_POSITION first_3_pos
from kronos_if.FIRST_3_CHARS_IN_POSITION a
<cfif isDefined('page.select_Sub_Group')>
where A.DEPTID || A.UNION_CD = ('#page.select_Main_Group#' || '#page.select_Sub_Group#')
</cfif>
)
order by first_3_pos
</cfquery>
<cfif isDefined('page.select_Sub_Group')>
<td align="center">
<select name="first3" id="first3" required="yes" onchange="this.form.submit()">
<option>Select</option>
<cfloop query="first3">
<option value="#first_3_pos#" <cfif isDefined('form.first3')><cfif form.first3 eq "#first_3_pos#">selected</cfif> </cfif>>#first_3_pos#</option>
</cfloop>
</select></td>
</cfif>
<cfif isdefined ("form.saverecord") and isdefined("form.newfirstchars")>
<cfquery name="saverec" datasource="mbtran">
insert INTO kronos_if.FIRST_3_CHARS_IN_POSITION
(deptid,union_cd, first_3_chars_in_position,effdt)
values('#page.select_Main_Group#','#page.select_Sub_Group#','#FORM.newfirstchars#',sysdate)
</cfquery>
</cfif>
</form>
Please advice. thanks

The query to INSERT the record is after the query you use to populate the drop down. You need to move this code
above the select queries.
You also want to look into using cfqueryparam – http://help.adobe.com/en_US/ColdFusion/10.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7f6f.html