erikTsomik
asked on
coldfusion button type="button"
I have coldfusion form where I need to update the selected option. So everything is qworking except that is does not update the dataabse
My JS is here
function saveSel (){
if (document.all) {
document.getElementById('r equirement s').option s[document .getElemen tById('req uirements' ).selected Index].tex t = document.getElementById('E ditDIV').v alue;
// document.getElementById('E ditDIV').v alue='';
document.getElementById('E ditDIV').s tyle.displ ay='none';
document.getElementById('m ainEditor' ).style.di splay='non e';
} else {
document.getElementById('r equirement s').option s[document .getElemen tById('req uirements' ).selected Index].tex t = document.getElementById('E ditDIV').v alue;
// document.getElementById('E ditDIV').v alue='';
document.getElementById('E ditDIV').s tyle.displ ay='none';
document.getElementById('m ainEditor' ).style.di splay='non e';
}
<cfif (isDefined("form.EditDIV") and isDefined("form.prereq2") and isDefined("form.hidden"))>
<cfdump var="#form#">
<cfparam name="form.EditDIV" default="">
<cfparam name="form.prereq2" default="">
<cfparam name="form.hidden" default="">
<cfparam name="requirements" default="">
<cfquery name="updateRequirements" datasource="HotBanana_Mana ger">
Update trnAcademicProgramRequirem ents
set requirement= '#HTMLEditFormat(form.Edit DIV)#', req_prereq='#HTMLEditForma t(form.pre req2)#' , hidden='#HTMLEditFormat(fo rm.hidden) #'
where reqid = #form.requirements#
</cfquery>
</cfif>
}
And the button is here
<input type="button" name="save" id="save" value="Save" onclick="saveSel();" >
My JS is here
function saveSel (){
if (document.all) {
document.getElementById('r
// document.getElementById('E
document.getElementById('E
document.getElementById('m
} else {
document.getElementById('r
// document.getElementById('E
document.getElementById('E
document.getElementById('m
}
<cfif (isDefined("form.EditDIV")
<cfdump var="#form#">
<cfparam name="form.EditDIV" default="">
<cfparam name="form.prereq2" default="">
<cfparam name="form.hidden" default="">
<cfparam name="requirements" default="">
<cfquery name="updateRequirements" datasource="HotBanana_Mana
Update trnAcademicProgramRequirem
set requirement= '#HTMLEditFormat(form.Edit
where reqid = #form.requirements#
</cfquery>
</cfif>
}
And the button is here
<input type="button" name="save" id="save" value="Save" onclick="saveSel();" >
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK. It does the same effect as was using submit button. What I need is to be able update the content and once the button is clicked see the changes without refreshing the page
What do you mean "without refreshing the page"? When you do a submit you're back on the server, just load the page with the new data before you redisplay it.
Or are you looking to do more of an Ajax update thing? In that case you'll need two CFM pages, one to load the page, and one to process the update. And then you'll need to use XMLHttpRequest to "call" the update page. If you're looking at Ajax I'd strongly recommend looking at the prototype.js (www.prototypejs.org) framework. I'm not associaed with it at all, other than a happy user!
-Walden
Or are you looking to do more of an Ajax update thing? In that case you'll need two CFM pages, one to load the page, and one to process the update. And then you'll need to use XMLHttpRequest to "call" the update page. If you're looking at Ajax I'd strongly recommend looking at the prototype.js (www.prototypejs.org) framework. I'm not associaed with it at all, other than a happy user!
-Walden
function saveSel (){
if (document.all) {
document.getElementById('r
// document.getElementById('E
document.getElementById('E
document.getElementById('m
} else {
document.getElementById('r
// document.getElementById('E
document.getElementById('E
document.getElementById('m
}
document.forms[0].submit()
}
<cfif (isDefined("form.EditDIV")
<cfdump var="#form#">
<cfparam name="form.EditDIV" default="">
<cfparam name="form.prereq2" default="">
<cfparam name="form.hidden" default="">
<cfparam name="requirements" default="">
<cfquery name="updateRequirements" datasource="HotBanana_Mana
Update trnAcademicProgramRequirem
set requirement= '#HTMLEditFormat(form.Edit
where reqid = #form.requirements#
</cfquery>
</cfif>
<input type="button" name="save" id="save" value="Save" onclick="saveSel();" >