function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
s_foos_foo 

How to disable InputField

Hi,
 
I have  scenario where i want to disable the inputField onload.
 
<apex:inputField id="sdate"   value="{!inputStartDate.Date__c}">

 
The value for input field is date.  Is there a way to do this?
 
Thanx
 
S
mtbclimbermtbclimber
why not use the rendered attribute and make toggle the visibility of inputField and an outputField for the same field?

s_foos_foo
Cann't do that coz i need to show the date on the screen
jwetzlerjwetzler
Did you understand the solution Andrew suggested?  Whatever logic you need for having the field be editable or disabled, you use that to determine whether to show an inputField or an outputField.  outputField will still show you the date, but your users won't be able to edit it.
s_foos_foo
My apologies. i understood what he mention after i replied back.  i will try this solution. One more question, how do i get rid of the date  displayed next to the input field?
s_foos_foo

Hi,

I  tried this solution but my problem is, i have to change the date on the basis of the SelectList on the same page and there is no rerender associated with SelectList, so how do I toggle between inputfield and outputfield without refreshing the page?

 

Thanx

S

 

 

 

jwetzlerjwetzler
look at actionSupport.  Lots of examples on the boards of people using actionSupport with selectList.
s_foos_foo
jill,
 
Thanx for all your valuable input. I am using actionsupport but in the action method am evaluating the value for selectList as follows. Is there a better way to access the value of Selectlist .
 
System.currentPageReference().getParameters().get('j_id0:stmtForm:headerBlock:datePickerDuration')
 
 
Thanx
 
S
jwetzlerjwetzler
You can't use DOM id's like that in your apex code.  I'm not sure what you're trying to do with the current page reference.

You access the value of selectList by calling the value attribute.  So if you have <apex:selectList value="{!myValue}"> then in your controller, you can call the same getMyValue() method that your page is calling.
s_foos_foo
Jill,
 
Thanx alot all your valuable help. I have implemented this one and the toggleing is working gr8. There are coupla other issues around that.
 
1. when i toggle for the first time, it gives me javascript error and doesn't show-up the calendar.
Line :16572
Char : 5
Error : Object Required
Code : 0
 
2. Is there way to show the earlier years in the calendar coz all this one is showing is years onward 2008 ?
 
 
Thanx
 
S
BDouglasBDouglas
I'm not sure how to implement this suggestion.  Do you have a code example of this?
Chamil MadusankaChamil Madusanka

Try following changes

 

<apex:inputField id="sdate" value="{!inputStartDate.Date__c}" onfocus="this.blur()">

 If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.

dat le ducdat le duc