Open Pop Up Box without using CSS
Page Code
<apex:page id="pg" controller="PopupScreenController">
<apex:form id="frm">
<apex:pageBlock title="PopUp" id="pb">
<apex:pagemessages id="msg"/>
<apex:commandButton value="Show Screen" onclick="opnePopup();" Oncomplete="refresh"/>
<script type="text/javascript">
var PopupBox;
var strreason;
var strcomment;
PopupBox = new SimpleDialog("test",false);
PopupBox.createDialog();
function opnePopup()
{
PopupBox.setTitle("PopUp Example");
PopupBox.importContentNode(document.getElementById("{!$Component.PopupBox}"));
PopupBox.show();
}
function callreason(res) { strreason = res; }
function callcomment(cmnt) { strcomment = cmnt; }
function checkreason()
{
if(strreason.length>0 && strcomment.length>0)
{
submitStandardPopup('Rejected',strcomment,strreason);
PopupBox.hide();
}
else
{
alert("Please Select reason or Enter comment");
}
}
</script>
<apex:outputPanel style="display:none">
<apex:outputPanel id="PopupBox" layout="block">
<b> Reason </b>
<apex:inputText id="reason" value="{!textReason}" onchange="callreason(this.value);" style="width:100%"/> <br/><br/>
<b>Commment</b>
<apex:inputText id="comment" value="{!textComment}" onchange="callcomment(this.value);" onblur="callcomment(this.value);" style="height:100px; width:100%"/> <br/><br/>
<center><apex:commandButton value="OK" onClick="checkreason();"/>
<apex:commandButton value="Cancel" onclick="PopupBox.hide();"/>
</center>
</apex:outputPanel>
</apex:outputPanel>
<apex:actionFunction name="submitStandardPopup" action="{!submitStandardPopup}" reRender="msg">
<apex:param name="status" value=""/>
<apex:param name="comment" value=""/>
<apex:param name="reason" value=""/> </apex:actionFunction>
</apex:pageBlock>
</apex:form>
</apex:page>
Class Code
public class PopupScreenController {
public string textReason{get;set;}
public string textComment{get;set;}
public PopupScreenController ()
{
textReason= '';
textComment='';
}
public void submitStandardPopup()
{
string statusval= ApexPages.currentPage().getParameters().get('status');
string reasonval= ApexPages.currentPage().getParameters().get('reason');
string commentval= ApexPages.currentPage().getParameters().get('comment');
if((reasonval!=null && reasonval.trim().length()>0)&&(commentval!= null && commentval.trim().length()>0))
{
ApexPages.addMessage( new ApexPages.Message(ApexPages.Severity.info,'Record Saved'));
}
}
}
Snap:
<apex:page id="pg" controller="PopupScreenController">
<apex:form id="frm">
<apex:pageBlock title="PopUp" id="pb">
<apex:pagemessages id="msg"/>
<apex:commandButton value="Show Screen" onclick="opnePopup();" Oncomplete="refresh"/>
<script type="text/javascript">
var PopupBox;
var strreason;
var strcomment;
PopupBox = new SimpleDialog("test",false);
PopupBox.createDialog();
function opnePopup()
{
PopupBox.setTitle("PopUp Example");
PopupBox.importContentNode(document.getElementById("{!$Component.PopupBox}"));
PopupBox.show();
}
function callreason(res) { strreason = res; }
function callcomment(cmnt) { strcomment = cmnt; }
function checkreason()
{
if(strreason.length>0 && strcomment.length>0)
{
submitStandardPopup('Rejected',strcomment,strreason);
PopupBox.hide();
}
else
{
alert("Please Select reason or Enter comment");
}
}
</script>
<apex:outputPanel style="display:none">
<apex:outputPanel id="PopupBox" layout="block">
<b> Reason </b>
<apex:inputText id="reason" value="{!textReason}" onchange="callreason(this.value);" style="width:100%"/> <br/><br/>
<b>Commment</b>
<apex:inputText id="comment" value="{!textComment}" onchange="callcomment(this.value);" onblur="callcomment(this.value);" style="height:100px; width:100%"/> <br/><br/>
<center><apex:commandButton value="OK" onClick="checkreason();"/>
<apex:commandButton value="Cancel" onclick="PopupBox.hide();"/>
</center>
</apex:outputPanel>
</apex:outputPanel>
<apex:actionFunction name="submitStandardPopup" action="{!submitStandardPopup}" reRender="msg">
<apex:param name="status" value=""/>
<apex:param name="comment" value=""/>
<apex:param name="reason" value=""/> </apex:actionFunction>
</apex:pageBlock>
</apex:form>
</apex:page>
Class Code
public class PopupScreenController {
public string textReason{get;set;}
public string textComment{get;set;}
public PopupScreenController ()
{
textReason= '';
textComment='';
}
public void submitStandardPopup()
{
string statusval= ApexPages.currentPage().getParameters().get('status');
string reasonval= ApexPages.currentPage().getParameters().get('reason');
string commentval= ApexPages.currentPage().getParameters().get('comment');
if((reasonval!=null && reasonval.trim().length()>0)&&(commentval!= null && commentval.trim().length()>0))
{
ApexPages.addMessage( new ApexPages.Message(ApexPages.Severity.info,'Record Saved'));
}
}
}
Snap:
Thanks
Sumit Shukla
sumitshukla.mca@gmail.com
skypeId: shuklasumit1
Comments
Post a Comment