+ Start a Discussion
Kalyani Jagdale 1Kalyani Jagdale 1 

How can we create input window after clicking on the command button?

How can we create input window after clicking on the command button?
Can anyone help me?
Ayush TripathiAyush Tripathi
So first create the command button 
   <apex:commandButton value="Show PopUp" action="{!ShowPopup}" reRender="pop" )}" />

Now in apex
 public void ShowPopup(){
        Popup = true;
    }
And the window you want to display

 <apex:outputPanel id = "pop" rendered="{!Popup }"/>
          Inside this you can write your code
<apex:outputPanel>
Kalyani Jagdale 1Kalyani Jagdale 1

Hi Ayush.
Thanks for your reply.
I have tried now, it's working.
I have one more querry..Can you help me.

When i Create an input window,and if Ispecify some amount. then it should split that amount and create a child record on that object.
How we can achieve this.
Thanks in advance.
Thanks & Regards,
Kalyani Jagdale

 

Ayush TripathiAyush Tripathi
Hi Kalyani
Please give some more detail. For my thinking, you are trying to insert amount into the child record. Can you make a new post for it with detailed explanation and can close this post if it is solved.
Kalyani Jagdale 1Kalyani Jagdale 1

Hi Ayush,
There is one field on parent Object i.e. Field1 and one field on child object i.e. Field2
i need to subtract Field1- Field2 (Subtract  field 2 from field1) and populate the subrated  result into the Input window field.


How  can we achieve this.
Can you please help me.

Sorry, i  have not closed this post. as it is related  to the above requirement.

Waiting for you reply  at the earliest.

Thank you in advance

 

Ayush TripathiAyush Tripathi
Hi Kalyani
 I have written some code for this but the problem which you might face will be 
How will you handle if there are more than 1 child record for parent Object. If you are sure that you will have only one record then you can use Limit 1. I have done it by taking the example of Account and Contact and by HardCoding the  Id. Further you cannot use inputField for this. So you have to use input:text.
<apex:page controller="solveQue">
    <apex:form>
       <apex:inputText value = "{!value}"/>
    </apex:form>
</apex:page>
 
public with sharing class solveQue {
    public Decimal value { get; set; }
    public Account acc  { get; set; }
    public Contact con  { get; set; }
    public solveQue(){
      acc = [Select Field1,Id from Account where Id = '0016F0000260SAe'];
      con = [Select Field2 from Contact where Account.Id =: acc.Id AND Id =: '0036F00002O0QE4'];  
        value = acc.Field1 - con.Field2;
    }
}

 
Kalyani Jagdale 1Kalyani Jagdale 1
Hi Ayush,
There will be multiple child record.