1

controller:

public with sharing class textInputsCon {
 public String inputText1{get;set;} // input text1 value  from vf
 public String inputText2{get;set;} // input text2 value  from vf   
 Public string operator{get;set;}
 public list<Quote__c>  quo{get;set;}       //this is will hold data to be displayed on page
// public list<Quote__c> quo1{get;set;}
 public void showlist(){ //do not return anything
 if(inputText1==null && inputText2==null)
quo= [select from1__c,Quote_number_new__c from quote__c];
if(inputText1!=null && inputText2==null)
quo= [select from1__c,Quote_number_new__c from quote__c where Quote_number_new__c=:inputtext1 ];
 }
 }

vfpage:

   <apex:page showHeader="false" sidebar="False" controller="textInputsCon">
    <apex:form >
       Input Text1 <apex:inputText value="{!inputText1}"/>
       Input Text2 <apex:inputText value="{!inputText2}"/>
      <apex:selectList id="operator" value="{!operator}" size="1">
            <apex:selectOption itemValue="=" itemLabel="Equal"/>
            <apex:selectOption itemValue="!=" itemLabel="Not equal to"/>
            <apex:selectOption itemValue="<=" itemLabel="Less than"/>
        </apex:selectList> 
        <apex:commandButton value="list" action="{!showlist}"/>
         <apex:pageBlock >
            <apex:pageBlockTable value="{!Quo}" var="q">
                <apex:column value="{!q.Quote_Number_New__c}"/>
                 <apex:column value="{!q.From1__c}"/>
            </apex:pageBlockTable> 

        </apex:pageBlock>
    </apex:form>
    </apex:page>

custom data

i want to query the user input and get results in the same page.how can i do that can any one correct this error

i want filter the records dynamically .if i type the input box "it has to filter records by teja" .if i type the second inputbox as sai .it has to calculate the records having teja and sai. i dont type any thing it has to show all records

1 Answer 1

1
public with sharing class textInputsCon {
     public String inputText1{get;set;} // input text1 value  from vf
     public String inputText2{get;set;} // input text2 value  from vf   
     public list<Quote__c>  quo{get;set;}//this is will hold data to be displayed on page


     public void showlist(){ //do not return anything
    quo= [select Quote_Number_New__c from quote__c where Quote_Number_New__c=:inputtext1 ];
     }
     }



<apex:page showHeader="false" sidebar="False" controller="textInputsCon">
    <apex:form >
       Input Text1 <apex:inputText value="{!inputText1}"/>
       Input Text2 <apex:inputText value="{!inputText2}"/>
        <apex:commandButton value="list" action="{!showlist}"/>
         <apex:pageBlock >
            <apex:pageBlockTable value="{!quo}" var="q">
                <apex:column value="{!q.Quote_new_number__c}"/> 
            </apex:pageBlockTable> 
        </apex:pageBlock> 
    </apex:form>
    </apex:page>
3
  • hi I have a selectlist of equal ,not equal to , less than ....how can i change logic in this query according to user input
    – Teja
    Feb 3, 2014 at 5:52
  • quo= [select Quote_Number_New__c from quote__c where Quote_Number_New__c=:inputtext1 ];
    – Teja
    Feb 3, 2014 at 5:53
  • For all kind of comparisons possible in SOQL, refer to section 'Comparison Operators'..salesforce.com/us/developer/docs/officetoolkit/Content/… Feb 3, 2014 at 6:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .