You need to sign in to do that
Don't have an account?
Javascript breaks my code
Hello,
I have a visualforce page which I am passing data from into apex code and using input from the page to update an object.
In this example I have a table of data, each ending with a checkbox and a text field. the text field is disabled until the user ticks the checkbox. at that point, I use javascript to enable the text field.
When the user is done they click a submit button which calls apex code.
This all works fine when I dont have the javascript involved. ie if the text box is always enabled, the data is passed and object updated fine, however when I do try and involve the javascript to enable/disable the text field as the checkbox is toggled, no data seems to be being passed from the text field and the object is not getting updated. well, it is, just not that text field.
Does anyone have any ideas why this would be happening and if it cannot be fixed, is there another way to link the textfield to the checkbox?
Thanks
Steven
actually now I've done more testing, it seems it works with the javascript, it is the fact that the text box is disabled on page load that is the problem. I want them disabled by default and only enabled when the checkbox is ticked. Why would having them disabled by default cause an issue?
Steven
I've tried rerendering with actionsupport instead but im having no luck. the boxes are initially not rendered since the checkboxes are not ticked, but when I do tick them, no text boxes reload :(
I've gone as far as to tell it to rerender the entire page (id OW_EditSubmission) but that doesnt seem to do anything
<apex:column headerValue="Edit?">
<apex:inputcheckbox id="tick" selected="false">
<apex:actionSupport event="onclick" rerender="OW_EditSubmission"/>
</apex:inputcheckbox>
</apex:column>
<apex:column headerValue="Change Required" id="comcol"> <apex:inputText maxLength="255" rendered="{!$Component.table.tick.selected == 'true'}" id="comment" value="{!li.Edit_Reason__c}" /></apex:column>
Yeah, this is still an issue. I even have the proper JavaScript code to set the disabled attribute to either "" or "disabled" instead of "true" or "false", but the value of the SelectList isn't being returned.
Figured out a solution. I have an apex:actionSupport element in the apex:inputCheckbox element, and re-render only the disabled control.