2 Replies Latest reply: Sep 1, 2013 3:51 PM by fac586 RSS

    How to Refer the Selected value in a Select List

    970829

      I have a page item which is a select list. I have a button in my region which when clicked will call a process. This process takes the current value of my page item as a parameter. However, when I select a value from the Select list and click on the button, the page item is still submitting the earlier value, it is not getting updated with the value I selected in the select list. Can someone tell me how I can get the page item value to be updated with the value I selected from the choice list? I tried calling a javascript function from the element attribute of this select list onchange="javascript:setValue(this);") and was trying to set the value of another hidden page item with the value of this select list but then the function is not getting called as well. My function code is something like


      function setValue(pThis)

      {

      for (var i = 0; i < pThis.options.length; i++) {

      if (pThis.options[ i ].selected){

      result= pThis.options;

      }

      html_GetElement('P2_HIDDEN').value = result;

      }

       

      P2_HIDDEN is my hidden page item


        • 1. Re: How to Refer the Selected value in a Select List
          jariola

          Hi,

           

          I just wonder why you need set select list value to hidden item?

          Is select list and hidden item in same page?

           

          I did read your other post about replace report column value with item value.

          Does this relate somehow that topic?

           

          Maybe you setup example about problem to apex.oracle.com and share developer login details to workspace.

           

          Regards,
          Jari

          • 2. Re: How to Refer the Selected value in a Select List
            fac586

            970829 wrote:

             

            I have a page item which is a select list. I have a button in my region which when clicked will call a process. This process takes the current value of my page item as a parameter. However, when I select a value from the Select list and click on the button, the page item is still submitting the earlier value, it is not getting updated with the value I selected in the select list.

            How do you know this? Have you used Debug mode to track what is happening when the button is pressed? This will show any changes to item values in session state during page submit and page show processing.

            Can someone tell me how I can get the page item value to be updated with the value I selected from the choice list?

            This should happen automatically with a select list item, if the button is correctly defined to perform a page submit. It will not happen if the button performs a redirect. What action is defined to occur when the button is pressed?

            I tried calling a javascript function from the element attribute of this select list onchange="javascript:setValue(this);") and was trying to set the value of another hidden page item with the value of this select list but then the function is not getting called as well. My function code is something like


            function setValue(pThis)

            {

            for (var i = 0; i < pThis.options.length; i++) {

            if (pThis.options[ i ].selected){

            result= pThis.options;

            }

            html_GetElement('P2_HIDDEN').value = result;

            }

             

            P2_HIDDEN is my hidden page item

            As detailed above, this should be completely unnecessary, however as an aside, html_GetElement is a very out of date method of accessing an item. What version of APEX are you using? (Always specify which version you're using when you ask a question, to allow us to determine the most appropriate solution to the problem.)