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
ccMarkccMark 

How do I get input type="text" data into my controller?

I have a section of code like this that I need to get working.   Basically, I have an autocomplete component that pulls data from a SOQL query on page load and I need to allow my user to pick a item from this list then push the data into {!currentRequestItem} on the controller.  When I debug, the value that's entered into the input text box never makes it to the controller in the commandButton action.  I can't use an <apex:inputText> control because it won't work with the autocomplete js I'm using.  Any ideas?

 

                <apex:outputpanel id="counter">                  
                    <input type="text" id="tb" value="{!currentRequestItem}">
                    <script>
                        var obj = actb(document.getElementById('tb'),customarray );
                    </script>
                    <apex:inputText value="{!currentQuantity}" />
                    <apex:commandButton value="Add Row" action="{!AddRow}"/>
                </apex:outputpanel>

XactiumBenXactiumBen

The only way to do it would be to have one of the apex components instead of your input text box.  You may have to transfer your input text box value into an apex component (maybe an inputHidden?) via javascript which then gets transferred to your controller.

ccMarkccMark

Anyone got any suggestions or can point me in the right direction for JS code to copy to a hidden component?

XactiumBenXactiumBen

Give this a go:

 

<apex:outputpanel id="counter"> <input type="text" id="tb" value="{!currentRequestItem}" onchange="document.getElementById('{!$Component.myHiddenInput}').value = this.value;"> <script> var obj = actb(document.getElementById('tb'),customarray ); </script> <apex:inputHidden id="myHiddenInput" value="{!myNewInput}" /> <apex:inputText value="{!currentQuantity}" /> <apex:commandButton value="Add Row" action="{!AddRow}"/> </apex:outputpanel>

 

Where {!myNewInput} is whatever variable you want to bind to in the controller.