+ Start a Discussion
Devendra@SFDCDevendra@SFDC 

Datepicker Pop Up Issue

Hi,

 

<select id="makeList" name="make" onfocus="this.select();">
<apex:repeat value="{!makeList}" var="lst">
<option value="{!lst}">{!lst}</option>
</apex:repeat>
</select>

 

<input type="text" id="promoDueDt1" name="promoduedt1" onfocus="DatePicker.pickDate(false,'promoDueDt1', false);" size="10"/>


I am using above code to display Datepicker on VF page. It display the datepicker. But at the time page load, datepicker pops up. I want to give setFocus to the select list and not to the datepicker at the time of pageload. The date picker should pop up only when user clicks on this field.

 

How can I give control to select list at the time of page load and stop popping up datepicker at the time of page load?

 

Thanks,
Devendra

Best Answer chosen by Admin (Salesforce Developers) 
Andy BoettcherAndy Boettcher

For the pop-up problem, that's a pretty common Visualforce thing.  To get it to go away, put this code immediately before the </apex:page> tag (the last line of your VF page before the close tag)

 

<script>
      setFocusOnLoad() {}
</script>

 -Andy

All Answers

SRKSRK

I belive that when page is load the focus is set at u r date picker

try to use tabindex="3"  so when the page is loaded it set the focus on the other field which have tabindex = "1"

Devendra@SFDCDevendra@SFDC

SRK,

 

Thanks for the response.

 

I have tried using tabindex, but it is not working. Still the page sets its focus on Datepicker and not on the select field :(

 

Thanks,

Devendra

 

 

SRKSRK

try this

<apex:page>

<head>

<script>

 var x = 0;

 

function showcal()

{

   if(x != 0)

   {

       DatePicker.pickDate(false,'promoDueDt1', false);

   }

}

</script>

</head>

<apex:form>

<input type="text" id="promoDueDt1" name="promoduedt1" onfocus="showcal()" size="10"/>

 </apex:form>

<script>

 x = 1;

</scipr>

</apex:page>

 

Devendra@SFDCDevendra@SFDC

Thank you once agin!

 

But it is also not working.

 

Thanks,

Devendra

 

SRKSRK

Is u cal is inside div
if yes then we can hide the div when page in load

SRKSRK

also do one this
if u try my soluction
then out a alert inside  "function showcal()" method & check this controler come inside this function when page load

 

Andy BoettcherAndy Boettcher

For the pop-up problem, that's a pretty common Visualforce thing.  To get it to go away, put this code immediately before the </apex:page> tag (the last line of your VF page before the close tag)

 

<script>
      setFocusOnLoad() {}
</script>

 -Andy

This was selected as the best answer
Devendra@SFDCDevendra@SFDC

Hello techman,

 

Its working now, your trick helped!!

 

<script>
      function setFocusOnLoad() {}
</script>

only setFocusOnLoad() giving me an error in javascript, adding function keyword to it got worked.

 

Thanks a lot..:)

 

Thanks,

Devendra