function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
shivam7388shivam7388 

I am not able to insert the record in database while i am able to calculate the value on page

Hi,

 

Below is my code.

 

Anyone help is appreciated.

 

 

<apex:page showheader="false" sidebar="false" action="{!PageLoadinitial}" controller="GTS_officehashEstimate_Controller">

 

 

function openpopup(){

//var check=document.getElementById('j_id0:sitepage_lite:form:j_id106:0:date').innerText ;
//alert(check);

document.getElementById('searchPopUp').style.display="block";
document.getElementById('blackContent').style.display="block";

}

function closewindow(){
alert('test');
//window.opener.focus();
}

function CloseWindow()
{

CloseLightBox();
}

function getsumTotalGBO(id){
var parameter = document.getElementById(id).value;
alert(parameter);
calculateTotalGBO(parameter);
}
function calculateremainingTotalAllocations(){
var arrData = [];
var gbototal = 0;
var admtotal = 0;
var scrtotal =0;

var totalgbosum = 0;
var totaladmsum = 0;
var ATMbyday =0;
var Maxscr =0;
wrapperlistsize = {!myWrappersList.size};


for(var i = 0;i<wrapperlistsize;i++){
var NaNcheck=parseFloat(document.getElementById('gbototal'+i).value);
var NaNadmcheck= parseFloat(document.getElementById('admtotal'+i).value)
var NaNadmscreen= parseFloat(document.getElementById('scrtotal'+i).value)
// GBO
if(isNaN(NaNcheck)!=true){
gbototal = parseFloat(document.getElementById('gbototal'+i).value);

totalgbosum = eval(totalgbosum) + eval(gbototal);
}
//Admission
if(isNaN(NaNadmcheck)!=true){
admtotal = parseFloat(document.getElementById('admtotal'+i).value);

totaladmsum = eval(totaladmsum) + eval(admtotal);

}
if(isNaN(NaNadmcheck)!=true && isNaN(NaNcheck)!=true){
ATMbyday =NaNcheck/NaNadmcheck;

}
if(isNaN(NaNadmscreen)!=true){
arrData.push(NaNadmscreen);
Maxscr= Math.max.apply(Math, arrData);
}

}

document.getElementById('TotalGBOsum').value=totalgbosum;
document.getElementById('TotalAdmissionsum').value=totaladmsum;
document.getElementById('atp').value=ATMbyday;
document.getElementById('Totalmaxscreen').value=Maxscr;

}







</script>
<style>
.black_overlay {
display: none;
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color: black;
z-index: 1001;
-moz-opacity: 0.2;
opacity: .40;
filter: alpha(opacity = 40);
}

.white_content {
display: none;
position: absolute;
top: 25%;
left: 20%;
width: 60%;
height: 60%;
padding: 1%;
//border: 2px solid blue;
background-color: white;
z-index: 1002;
overflow: auto;
}
</style>


<apex:composition template="GTS_SiteTemplate_Lite">
<apex:define name="dataDisplay">
<c:GTS_Navigation_Menus inputDropId="2" showL2Menu="false"/>
<br/>
<apex:form id="form">

<p>
<h1>
<apex:outputlabel value="hash Estimate Comment"></apex:outputlabel>
<!--<apex:commandButton styleClass="alignright Addbutton" immediate="false" Action="{!saveText}" title="Add Record" ></apex:commandButton>-->
<input type="button" class="btn" onclick="return savehashestimatebyday(); return false;" image="{!URLFOR($Resource.GTS_images,'buttons/create_up.png')}"/>

</h1>
<tr>
<td>

</td>

</tr>
<table width="100%" >
<tr>
<th width="140">
Time Period
</th>
<td>
<apex:outputText value="{!TimePeriod}" id="check"/>
<!-- <apex:inputField value="{!gffspd.Play_Date__c}"/>-->
</td>
<th width="140">
Week Ending Date
</th>
<td>
<apex:outputText value="{!Weekend}" id="check1"/>
<!-- <apex:inputField value="{!gffspd.Play_Date__c}"/>-->
</td>
</tr>
</table>
</p>
<br/>
<br></br>
<br></br>

<h2 style="margin:0 0 0 0">
<apex:outputlabel value="Days Reported"></apex:outputlabel>
</h2>
<table width="100%">

<tr>
<th width="140">Time Period Rental Ratio</th>
<td>
<apex:inputfield value="{!gffspd.Time_Period_Rental_Ratio__c}" />
</td>
<p></p>
<th width="140">Currency</th>
<td>
<apex:outputText value="{!strcurrency}"/>
</td>
</tr>

<tr>
<tr></tr>
<tr></tr>
<th>Play Week#</th>

<td>
<apex:outputText value="{!diffrence}"/>
</td>
</tr>
</table>
<br></br>
<br></br>
<apex:actionFunction action="{!Add}" name="Addrow" immediate="flase" reRender="popup"></apex:actionFunction>
<apex:actionFunction action="{!saveText}" name="savehashestimatebyday" immediate="flase" reRender="dummy"></apex:actionFunction>
<apex:actionFunction name="calculateTotalGBO" action="{!caltotalGBO}" rerender="displayresult2">
<apex:param name="GBOvalue" value="" />
</apex:actionFunction>
<div id="blackContent" class="black_overlay"></div>
<div id="searchPopUp" class="white_content">
<script>
function sumtotalgbo(){
var admfor = 0;
var gbofor = 0;

var totalgbosumfor = 0;
var totaladmsumfor = 0;
var ATMbydayfor =0;

wrapperlistsize = {!lstInner.size};


for(var i = 0;i<wrapperlistsize;i++){
var NaNcheckfor=parseFloat(document.getElementById('gbofor'+i).value);
var NaNadmcheckfor= parseFloat(document.getElementById('admfor'+i).value)
// GBO
if(isNaN(NaNcheckfor)!=true){
gbofor = parseFloat(document.getElementById('gbofor'+i).value);

totalgbosumfor = eval(totalgbosumfor) + eval(gbofor);
}
//Admission
if(isNaN(NaNadmcheckfor)!=true){
admfor = parseFloat(document.getElementById('admfor'+i).value);

totaladmsumfor = eval(totaladmsumfor) + eval(admfor);

}
if(isNaN(NaNadmcheckfor)!=true && isNaN(NaNcheckfor)!=true){
ATMbydayfor =NaNcheck/NaNadmcheck;

}

}

document.getElementById('TotalGBOsumfornew').value=totalgbosumfor;
document.getElementById('TotalAdmsumfornew').value=totaladmsumfor;
document.getElementById('atpfor').value=ATMbydayfor;

}





</script>

<apex:outputpanel id="popup">
<h>GBO By Format</h>
<apex:image styleClass="alignright" onclick="CloseWindow();" URL="{!URLFOR($Resource.GTS_images,'icons/x_icon_B1BBC7.png')}" />
<table style="width:100%;" id="GBOtable">
<tr>



<td style="font-weight: bold;">
&nbsp;&nbsp;<!--<apex:commandbutton image="{!URLFOR($Resource.GTS_images,'buttons/create_up.png')}" id="addbutton" onclick="return Addrow(); return false;" /> -->
<input type="button" class="btn" onclick="return Addrow(); return false;" image="{!URLFOR($Resource.GTS_images,'buttons/create_up.png')}"/>
</td>
<td style="font-weight: bold;">
&nbsp;&nbsp;<apex:commandbutton image="{!URLFOR($Resource.GTS_images,'buttons/save_up.png')}" id="savebutton" action="{!Savegboformat}" />
</td>
<td>
<apex:outputText />
</td>
</tr>
</table>

<apex:outputpanel id="displayresult2" >



<table cellspacing="1" class="tablesorter,standardtable" style="margin-top:10px">
<thead>
<tr>
<th Class="leftheading">Format</th>
<th Class="leftheading">Admission</th>
<th Class="leftheading">GBO</th>
<th Class="leftheading">Avg. Ticket Price</th>

</tr>
</thead>
<tbody>
<apex:variable var="rptIndexnew" value="{!-1}" />
<apex:repeat var="wrapper" value="{!lstInner}">
<apex:variable var="rptIndexnew" value="{!rptIndexnew+1}"/>
<apex:outputtext value="{!rptIndexnew}"/>
<tr>
<td>
<apex:inputField value="{!wrapper.gbf.Format__r.name}" id="namefor" ></apex:inputField>
</td>
<td>
<input type="text" value="{!wrapper.gbf.Admission__c}" id="admfor{!rptIndexnew}" />
</td>
<td>
<input type="text" value="{!wrapper.gbf.GBO__c}" id="gbofor{!rptIndexnew}" />
</td>
<td>
<input type="text" value="{!wrapper.gbf.ATP__c}" id="atpfor" readonly="true" style="border: none" />
</td>
<td>
<apex:commandButton value="X" action="{!Del}" rerender="pb1">
<apex:param name="rowToBeDeleted" value="{!wrapper.recCount}" assignTo="{!selectedRowIndex}"></apex:param>
</apex:commandButton>
</td>

</tr>
</apex:repeat>
<tr>

<td colspan="1">
Total
</td>
<td>
<input type = "text" value="" id="TotalGBOsumfornew" readonly="true" style="border: none"/>
</td>
<td>
<input type = "text" value="" id="totaladmsumfornew" readonly="true" style="border: none"/>
</td>
</tr>
</tbody>
</table>
<!-- End of Display area for a Pagination table -->

</apex:outputpanel>

<!-- <input type="button" class="btn" value="Clear All" onclick="clearsearch()" /> -->
</apex:outputpanel>

</div>
<table id="Estimatedata" class="standardtable" style="margin-top:10px">

<tbody>
<tr>
<th width="240" class="leftheading">
Day
</th>
<th width="240" class="leftheading">
Date
</th>

<th width="240" class="leftheading">
GBO
</th>
<th width="240" class="leftheading">
Screens
</th>
<th width="240" class="leftheading">
Admission
</th>
<th width="240" class="leftheading">
ATP
</th>
<th width="240" class="leftheading">
GBO
</th>
<th width="240" class="leftheading">
Screens
</th>
<th width="240" class="leftheading">
Admission
</th>
<th width="240" class="leftheading">
ATP
</th>
<th width="240" class="leftheading">

</th>
</tr>
<apex:outputpanel id="hashestimatebyday">
<apex:variable var="rptIndex" value="{!-1}" />
<apex:repeat var="wrapper" value="{!myWrappersList}">
<apex:variable var="rptIndex" value="{!rptIndex+1}"/>
<!--<apex:outputtext value="{!rptIndex}"/>-->
<tr>
<td>
<apex:outputlabel value="{!wrapper.obj1.Day__c}"></apex:outputlabel>
</td>

<td>
<apex:outputText value="{0,date,MM'/'dd'/'yyyy}" id="date">
<apex:param value="{!wrapper.obj1.Date__c}" /></apex:outputText>
</td>
<td>
<input type="text" value="{!wrapper.obj1.GBO__c}" id="gbototal{!rptIndex}" onchange="calculateremainingTotalAllocations()" />
<a name="theLink" onclick="openpopup(); return false;">GBO By Format</a>
</td>

<td>
<input type="text" value="{!wrapper.obj1.Screens__c}" id="scrtotal{!rptIndex}" onchange="calculateremainingTotalAllocations()"/>
</td>
<td>
<input type="text" value="{!wrapper.obj1.Admission__c}" id="admtotal{!rptIndex}" onchange="calculateremainingTotalAllocations()"/>
</td>
<td>
<input type="text" value="{!wrapper.obj1.ATP_by_Day__c}" id="atp" readonly="true" style="border: none"/>
</td>
<td>
<apex:outputText value="{!wrapper.obj2.GBO__c}" ></apex:outputText>
</td>
<td>
<apex:outputText value="{!wrapper.obj2.Screens__c}" ></apex:outputText>
</td>
<td>
<apex:outputText value="{!wrapper.obj2.Admission__c}" ></apex:outputText>
</td>
<td>
<apex:outputText value="{!wrapper.obj2.ATP__c}" id="atp3" ></apex:outputText>
</td>
<td>
<a name="theLink" onclick="selecttitles('{!$Component.check}','{!$Component.terrid}');">Theatres Reported</a>
</td>


</tr>
</apex:repeat>
</apex:outputpanel>
<tr>

<td colspan="2">
Total
</td>
<td>
<input type = "text" value="" id="TotalGBOsum" readonly="true" style="border: none"/>
</td>
<td>
<input type = "text" value="" id="Totalmaxscreen" readonly="true" style="border: none"/>
</td>
<td>
<input type = "text" value="" id="TotalAdmissionsum" readonly="true" style="border: none"/>
</td>
</tr>
</tbody>

</table>
<br></br>
<br></br>
<h2 style="margin:0 0 0 0">
<apex:outputlabel value="Comment"></apex:outputlabel>
</h2>
<table>
<tr>
<tr></tr>
<tr></tr>

<th width="140">Assesment</th>
<td>
<apex:inputField value="{!gffspd.Assesment__c}" />
</td>
<th width="140">Notes</th>
<td>
<apex:inputText value="{!gffspd.Territory_Comment__c}" />
</td>
</tr>


</table>


<br></br>
<br></br>
<h2 style="margin:0 0 0 0">
<apex:outputlabel value="Proposed Revised GBO Estimate"></apex:outputlabel>
</h2>
<br></br>
<br></br>
<table>
<tr>
<th width="140">Current Estimate</th>
<td>
<apex:outputText value="{!gffspd.Current_Estimate__c} " />
</td>
<th width="140">Proposed Revise GBO Estimate</th>
<td>
<apex:inputText value="{!gffspd.Proposed_Revised_GBO_Estimate__c}" />
</td>
</tr>


</table>
<table id="Estimatedata" class="standardtable" style="margin-top:10px">

<tbody>
<tr>
<th width="240" class="leftheading">
Action
</th>
<th width="240" class="leftheading">
Date
</th>

<th width="240" class="leftheading">
Status
</th>
<th width="240" class="leftheading">
AssignedTo
</th>
<th width="240" class="leftheading">
Actual Approver
</th>
<th width="240" class="leftheading">
Comments
</th>
<th width="240" class="leftheading">
Overall Status
</th>

</tr>
<apex:outputpanel >

<apex:repeat var="wrapper">

<!--<apex:outputtext value="{!rptIndex}"/>-->
<tr>
<td>
<apex:outputlabel ></apex:outputlabel>
</td>
<td>
<apex:outputlabel ></apex:outputlabel>
</td>
<td>
<apex:outputlabel ></apex:outputlabel>
</td>
<td>
<apex:outputlabel ></apex:outputlabel>
</td>
<td>
<apex:outputlabel ></apex:outputlabel>
</td>
<td>
<apex:outputlabel ></apex:outputlabel>
</td>
<td>
<apex:outputlabel ></apex:outputlabel>
</td>




</tr>
</apex:repeat>
</apex:outputpanel>

</tbody>

</table>
</apex:form>
</apex:define>
</apex:composition>
</apex:page>

Raj_Raj_

what error are you getting and where ?

shivam7388shivam7388
I am not getting error but my values are not getting inserted in object
Raj_Raj_
where is your controller?
Kamatchi Devi SargunanathanKamatchi Devi Sargunanathan

Hi,

 

You have to check the function 'saveText' you have used in action function instead of commandbutton. In that function you should have the insert operation in controller.

 

Check you code in the below line,

 

<apex:actionFunction action="{!saveText}" name="savehashestimatebyday" immediate="flase" reRender="dummy"></apex:actionFunction>

 

 

Hope this will solve your issue...!