You need to sign in to do that
Don't have an account?
bela
regarding script in visualforce
can any one please,help to solve below problem regarding java script for the below code
I am checking database value in java script [controller: pos=Database.query(holdString);] when pos contains letter which dont have records ,it should display no records found (eg: if letter x is entered it should display no records found if there are no records with X),i am trying as i mentioned above in script but i think its not the write way,this i achived through controller, but i want this validation through javascript, please help me.
as i am new to javascript,pls help me to understand.
<apex:page controller="searchwithactionstatuscontroller" id="one">
<script>
function js(value){
var inputValue = document.getElementById(search).value;
alert(inputValue );
if(inputValue==null||inputValue==''){
alert('no records found');
}
else{
actionFunName();
}
}
</script>
<apex:form id="two">
<apex:actionFunction name="actionFunName" action="{!searchpositions}" reRender="two" />
<apex:outputLabel for="search" value="SEARCH :" style="font-weight:bold" />
<apex:inputText value="{!search}" id="search" onkeyup="js(value)" />
<!--<apex:actionSupport event="onkeyup" action="{!searchpositions}" reRender="one:two:block1"/>-->
<apex:outputText id="error" value="{!error}" />
<apex:pageBlock rendered="{!blockOnLoad}" id="block1">
<apex:pageBlockSection >
<apex:pageBlockTable value="{!poslis}" var="pl" >
<apex:column value="{!pl.name}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock rendered="{!blockOnEnter}" >
<apex:pageBlockSection id="d">
<apex:pageBlockTable value="{!pos}" var="p" >
<apex:column value="{!p.name}"/>
<apex:column >
<apex:inputCheckbox value="{!p.name}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
controller
---------------
public with sharing class searchwithactionstatuscontroller {
public String error { get; set; }
public boolean blockOnLoad{set;get;}
public boolean blockOnEnter{set;get;}
public PageReference searchpositions() {
string holdString ='SELECT name from Position__c where name like \'%'+search+'%\' ORDER BY name asc';
pos=Database.query(holdString);
blockOnLoad=false;
blockOnEnter=true;
return null;
}
public String search { get; set; }
public List<position__c> poslis{set;get;}
public List<position__c> pos{set;get;}
public searchwithactionstatuscontroller() {
poslis=[select Name from position__c];
blockOnLoad=true;
blockOnEnter=false;
}
}
I am checking database value in java script [controller: pos=Database.query(holdString);] when pos contains letter which dont have records ,it should display no records found (eg: if letter x is entered it should display no records found if there are no records with X),i am trying as i mentioned above in script but i think its not the write way,this i achived through controller, but i want this validation through javascript, please help me.
as i am new to javascript,pls help me to understand.
<apex:page controller="searchwithactionstatuscontroller" id="one">
<script>
function js(value){
var inputValue = document.getElementById(search).value;
alert(inputValue );
if(inputValue==null||inputValue==''){
alert('no records found');
}
else{
actionFunName();
}
}
</script>
<apex:form id="two">
<apex:actionFunction name="actionFunName" action="{!searchpositions}" reRender="two" />
<apex:outputLabel for="search" value="SEARCH :" style="font-weight:bold" />
<apex:inputText value="{!search}" id="search" onkeyup="js(value)" />
<!--<apex:actionSupport event="onkeyup" action="{!searchpositions}" reRender="one:two:block1"/>-->
<apex:outputText id="error" value="{!error}" />
<apex:pageBlock rendered="{!blockOnLoad}" id="block1">
<apex:pageBlockSection >
<apex:pageBlockTable value="{!poslis}" var="pl" >
<apex:column value="{!pl.name}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock rendered="{!blockOnEnter}" >
<apex:pageBlockSection id="d">
<apex:pageBlockTable value="{!pos}" var="p" >
<apex:column value="{!p.name}"/>
<apex:column >
<apex:inputCheckbox value="{!p.name}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
controller
---------------
public with sharing class searchwithactionstatuscontroller {
public String error { get; set; }
public boolean blockOnLoad{set;get;}
public boolean blockOnEnter{set;get;}
public PageReference searchpositions() {
string holdString ='SELECT name from Position__c where name like \'%'+search+'%\' ORDER BY name asc';
pos=Database.query(holdString);
blockOnLoad=false;
blockOnEnter=true;
return null;
}
public String search { get; set; }
public List<position__c> poslis{set;get;}
public List<position__c> pos{set;get;}
public searchwithactionstatuscontroller() {
poslis=[select Name from position__c];
blockOnLoad=true;
blockOnEnter=false;
}
}