Passing collection in JSTL html:select onChange event javascript

I'm trying to pass an object from the form to a javascript function to change text box values when the value of a select field is changed.
On the jsp page, I have access to the collection called rows.
I also have an html:select field that I need to use the onChange event to change other fields on the page. I can certainly call a javascript function on the onChange with no problem. But I need to take it one step further. I need to send the javascript function the collection called rows, so I can set other fields' values on the jsp page to the values of the selected row.
This (or some facimile) is what I want to do:
<html:select name="currentForm" property="value(id)" onChange="fillUomForm(this.form,this,rows);">
  <c:forEach var="row" items="${rows}">
      <c:choose>
           <c:when test='${row.id == currentForm.stringValues["id"]}'>
                <option value="<c:out value='${row.id}'/>" selected>
                     <c:out value="${row.id}"/>
                </option>
           </c:when>
           <c:otherwise>
                 <option value="<c:out value='${row.id}'/>">
                    <c:out value="${row.id}"/>
                 </option>
           </c:otherwise>
       </c:choose>
    </c:forEach>
</html:select>Of course, rows is not recognized when I try to run this.
I have tried replacing rows with
<c:out value='${rows}'/> but that did not work.
How can I do this?
thanks,
Walter

sigh.
Another user mixing up JAVA and javaSCRIPT.
Java runs on the server. It generates an HTML page, and stops running.
When the client receives the HTML page it can start running javascript.
The only way java code is run again is if you make another http request. - ie the next time you click a link or submit a form.
Most of the time that results in reloading a new page.
You have two options
1 - Download all the information you might possibly want/need as part of the JSP page. Then the javascript onclick event can retrieve it from javascript memory.
2 - Make the onchange event submit an HTTP request, and then pick up the response, and do with it what it will. AJAX is a technology that lets you update the page without refreshing it completely.
Hope this helps,
evnafets

Similar Messages

  • Html:select onchange

    Hi,
    In html:select tag, i'm using onchange function to submit the page. The problem here is, after selecting a value, if I immediately select another from the combo,it again submits but the page renders with blank page. is there is anyother way to solve this??
    thanks in advance.

    yeah, don't do that.
    You can force not doing that by doing this:
    ... onchange="theSubmitThing(); this.disabled = true;" ...

  • Javascript:genList to trigger html input onChange event

    I converted a select list to a popup lov because my users liked the quick search of the popup lov. But no I no longer have the onChange event of the select input. Is there a way to customize this genList function, maybe by encapsulating the call into another javascript function to get this on change functionality back?

    Well I was able to code around this by re-writing the genList javascript function at runtime in the web client. An alternative I guess would be to use HTMLDB_ITEM and build my items and form within a PL/SQL region.

  • Firefox 35 & 36 on Mac don't select listboxes (html select) created by javascript / jquery, unless I set focus programmatically or I right-click on it.

    I am creating a single page app and newly created <select></select> does not work. It seems the problem is these select do not get focus when I click on it. If I (1) set focus programmatically; or, (2) rigth-click on it, it works normally. Firefox 35 / 36 on Mac OSX 10.10.2.

    Hi, there. I tried to make a simple sample case... but it worked. My application is a backbone based dashboard panel. The problem occurs in some special condition I am trying to replicate. I the following links it was related to jquery.ui.modal window and datepickers. It is not my case, but I guess I am using something similar to modal windows.
    I guess to case are related:
    1. [https://support.mozilla.org/en-US/questions/964354 Select does not open dropdown onclick]
    2. [http://stackoverflow.com/questions/22050641/month-select-in-datepicker-inside-a-bootstrap-modal-wont-work-in-firefox Month select in datepicker inside a bootstrap-modal won't work in Firefox]
    If I succeed replicating the case, I will post it here.
    Thanks!

  • Dynamically change onchange event of select control of html

    Can I dynamically the onchange event of select control of html?
    i..e. change the task to be done when the onchange event is triggered.
    Thanks in advance

    Yes.
    At what point do you want to change it?
    What do you want to change it to?
    If you are generating the page, you can obviously produce different code behind the button using JSP to generate javascript code.
    eg
    function alertUser(){
      alert('<%=  alertMessage %>');
    }That will produce a different function every time you load the page, depending on the variable "alertMessage".
    You can also replace javascript handlers at runtime, just by simply assigning functions. However you at the client end you are only able to run javascript - no java.
    eg
    function alertUser1(){
      alert("action a");
    function alertUser2(){
      alert("action b");
    <button id="button1" onclick="alertUser1()">Alert!</button>
    <button onclick="button1.onclick=alertUser2">Alert!</button>Does that help?

  • Have an onchange event in SPD to update a list based on user selection of data view drop down?

    Hoping someone can point me in the right direction: I have a list for Media announcements, each one of these announcements will have various types of documents associated (via look up field in the doc library). I am trying to have a data form web part (dropdown)
    as the selector (as I am not liking the SharePoint list filter feature) to have a user be able to select the Media Title, then it refreshes the three web parts on the page (1 for the announcement, then one for type1 docs and one for type 2 docs.)
    What is the best way to create an onchange event to have the selected option be connected to the first web part (media title on a list view) so that the information on the page can all be filtered?

    Hi,
    Would you mind providing more details about your requirement? Are there one Announcements list and two Document Library in a page?
    Suppose you have one Announcements list and two Document Library in a page, then you want to add a Drop Down Menu(not the OOTB SharePoint List Filter Web Part) to filter the
    three List View Web Part dynamically.
    There will be two workarounds:
    1. Use the OOTB “Connections” feature of the list to “Get Filter Values From” one of the three lists, then there will be a “Select” button in that list, we can click it to filter
    other two lists/libraries. This is a way without code though we may not have the Drop Down Menu;
    2. Add three <iframe> in a page, then add a Drop Down Menu in this page. Now, we will need some JavaScript to listen to the onchange event of this Drop Down Menu. We can
    get the values populated in the Drop Down Menu from one of the column of one of the list, when making a selection in it, we can pass an URL with query strings to the three iframes which will show the three different lists or libraries.
    The second way requires some code to interact with Client Object Model cause we need to get values from a list, some script to handle the onchange event, which seems more suit
    with your need.
    Here are some links might be helpful if you want to take the second way:
    About how to find a specific element on a page using JavaScript:
    http://javascript.info/tutorial/searching-elements-dom
    Handle the onchange event using jQuery.change function:
    http://api.jquery.com/change/
    About query string to filter a list view:
    http://techtrainingnotes.blogspot.com/2012/03/sharepoint-search-filter-or-sort-lists.html
    About change the src attribute of iframe:
    http://stackoverflow.com/questions/3730159/changing-iframe-src-with-javascript
    http://www.w3schools.com/jsref/prop_frame_src.asp
    Best regards
    Patrick Liang
    TechNet Community Support

  • Problem in submiting the form onchange of html:select

    I am using WSAD 5.0 and working on a small application with struts.
    I have following code where I want to submit the form if user selects any option from the list. Problem is when i select any option it is giving error that this property is not supported. Following is my code
    <html:form action="/NewUserAction1">
    <tr>
                   <td>
                        <font color="Blue">
                             <b><bean:message key="NewUser1.CountryName" /></b>
                        </font>*
                   </td>
                   <td>
                        <html:select property="state" onchange="submit();">
                             <html:option value="default">select state</html:option>
                             <html:option value="bangalore">Bangalore</html:option>
                             <html:option value="delhi">Delhi</html:option>
                        </html:select>
                   </td>
              </tr>
         </html:form>
    Please help me someone why i am not able to submit the form on onchange event of <html:select>
    Thanks.

    I got the solution :)
    Finally I figured out that
    by default, struts gives <html:submit/> tags a name of
    "submit". Thus there was a namespace collision in the
    form object, with the submit button overriding the
    form's submit method. I fixed the problem by changing
    the name of the submit button. Something like this
    works great:
    <html:submit property="submitPage">
                        <bean:message key="NewUse1.Submit"/>
                   </html:submit></td>
    Now i am able to submit the form.
    Thanks alot.

  • Select list - Onchange event

    I want to add an onchange event in a form for a Select list.
    For that i had written two javascript functions and two application process.
    In HTML Form Element Attributes of the Select List, I had written the following :
    style="font-family:Franklin Gothic Medium;font-size:12px;width:160px";onchange="f_bomqty()";onchange="f_rmc();"
    But, when change the Select List item, the onchange event happens for obly the first function ie. onchange="f_bomqty()";
    Please suggest, whether anything is wrong in In HTML Form Element Attributes ?
    Can we populate two Textfields at the same time, for an Onchange event of a select list ?
    Yogesh

    No change. Please check if anything is wrong in javascripts and application process.
    The javascript code and application process are as follows :
    Javascripts
    <script language="JavaScript" type="text/javascript">
    htmldb_delete_message='"DELETE_CONFIRM_MSG"';
    function f_bomqty()
    var lVal = $v('P10_CR_BOM_CODE');
    var get = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=BOMQTY',0);
    get.add('P10_CR_BOM_CODE',lVal);
    var gReturn = get.get();
    if(gReturn){
    $x_Value('P10_CR_QUANTITY', gReturn);
    } else {
    $x_Value('P10_CR_QUANTITY', '');
    get = null;
    function f_rmc()
    var lVal = $v('P10_CR_BOM_CODE');
    var get = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=RMC',0);
    get.add('P10_CR_BOM_CODE',lVal);
    var gReturn = get.get();
    if(gReturn){
    $x_Value('P10_CR_RMC', gReturn);
    } else {
    $x_Value('P10_CR_RMC', '');
    get = null;
    </script>
    Application process : - BOMQTY
    DECLARE
    BQTY NUMBER;
    ERROR VARCHAR2(200);
    BEGIN
    SELECT CR_QUANTITY INTO BQTY
    FROM CM_RECIPE
    WHERE CR_BOM_CODE = :P10_CR_BOM_CODE;
    HTP.prn (BQTY);
    EXCEPTION
    WHEN OTHERS
    THEN HTP.prn (sqlerrm);
    END;
    Application process : - RMC
    DECLARE
    RMC NUMBER;
    ERROR VARCHAR2(200);
    BEGIN
    SELECT RMCCOST
    INTO RMC
    FROM
    SELECT SUM(CRI_QTY * CRI_RM_COST) / CR_QUANTITY RMCCOST
    FROM CM_RECIPE, CM_RECIPE_ITEM
    WHERE CR_BOM_CODE = :P10_CR_BOM_CODE
    AND CR_ID = :P10_CR_ID
    GROUP BY CR_QUANTITY
    HTP.prn (RMC);
    EXCEPTION
    WHEN OTHERS THEN
    ERROR := 'Error - Cannot calculate the RMC';
    HTP.prn (ERROR);
    END;
    Yogesh

  • How to pass tabular report col reference in the onChange event of Txtfield

    Hi there
    I need to have Onchange event on Textfield Item.
    Whenever i change the text field value, the new value should go to particular column in my
    tabular report.
    So in the onchange event, i have to pass the tabular report column (target field) along with textfield value (this.value)
    something like this:
    onChange="javascript:changeColVal(this,rowid);"
    I have no clue how to pass row id / particular column of tabular report in textfield.
    Any pointers on this would be of great help.
    Thanks
    Vijay

    Hi Andy
    Thanks a ton for your reply.
    The above solution would work fine when we refer Text field within that tabular report.
    but if we refer text field Item from separate HTML region?
    I'm sorry, its my mistake for not providing OTN application for reference.
    I've come up with dummy application which shows you exact requirement.
    Please follow url: http://apex.oracle.com/pls/otn/f?p=47869:21
    login credentials:
    workspace: vsanthanam
    user: vijay
    pswd: apex_demo
    Application highlights the row whenever we move up/down or click the row.
    Here, i've NOTES in tabular report and Comments "text field" in separate HTML region.
    Whenever i type/update comments in textfeild, it should goto Notes column in Tabular report.
    so that when we move up/down the tabular report rows, it should show corresponding Notes in Comments text field.
    Approach i've took:
    1) Created a function hiliterow, that highlights the row clicked/move up or down and
    also displays the Notes Column of Tabular report into Comments Textfield.
    (this is to display Notes if already avail to that particular row, otherwise Null)
    2) Function passValues would assign the value we type in Comments Text field to
    Notes column of Tabular Report. (as of now, this is happening only when we click on that particular row after key-in the value in Comments txtfield,
    but this should happen when onChange event on comment textfield)
    3) In MoveupDown function, i'm refering the current row in var r. so i tought to have global var to hold current row, so that i can
    refer the same row in Onchange Event of Textfield. But this fails (please refer NotesToRow function)
    My requirement is to pass the Comments text field value to Tabular report when onChange event on Comments Text feild happens.
    I'm helpless in passing row reference to onChange function.
    Any pointer on this would be of immense help.
    Thanks
    vijay

  • Tabular Form : Select list : onchange event

    I need a method / example to apply an Onchange event to a Select List in Tabular form.
    Whenever an item from the select list is selected, the data from other column of the same or different Table should get displayed,
    in a Textfield of the Tabular form.
    Yogesh

    Hi,
    Here is one example
    http://apex.oracle.com/pls/otn/f?p=31517:176
    Br, Jari

  • Pass collections into to select query on IN caluse

    Hi friends,
    I wanted to pass collections in to select query IN caluse .
    Eg..
    Declare
    type tab is table of varchar2(25);
    v_tab tab:
    type tab1 is table of varchar2(25);
    v_tab1 tab:
    Begin
    select ename into v_tab from emp where deptno in (10,20,30);
    select location into v_tab1 emp_hist where ename in ( v_tab1 ); -- here where i wnt to pass the collections
    End;
    i dont want to write an loop to do this , i like to use only collections ? any idea how
    thanks in advance .
    Raj

    Hi Raj,
    In the examples above you will need to have a type declared in the database, however you can create a pipelined function to do what you want... something like this,
    SQL> Create OR Replace Package My_Types Is
      2 
      3     Type enames_tab Is Table Of Varchar2(50);
      4 
      5  End My_Types;
      6  /
    Package created
    SQL> Create OR Replace Function lookup_ename Return my_types.enames_tab
      2     Pipelined Is
      3     v_row   my_types.enames_tab;
      4     cur     Sys_Refcursor;
      5     v_ename Varchar2(50);
      6  Begin
      7     v_row := my_types.enames_tab();
      8     Open cur For
      9        SELECT ename
    10          FROM emp
    11         WHERE ename IN ('SMITH', 'JAMES', 'WARD');
    12     Loop
    13        Fetch cur
    14           INTO v_ename;
    15        Exit When cur%Notfound;
    16        v_row.Extend;
    17        v_row(v_row.Count) := v_ename;
    18        Pipe Row(v_row(v_row.Count));
    19     End Loop;
    20     Return;
    21  End;
    22  /
    Function created
    SQL> Set Serveroutput on;
    SQL> Declare
      2     v_tab my_types.enames_tab;
      3  Begin
      4     SELECT ename Bulk Collect
      5       INTO v_tab
      6       FROM emp
      7      WHERE ename IN (SELECT *
      8                        FROM Table(lookup_ename));
      9 
    10     For i IN v_tab.First .. v_tab.Last Loop
    11        dbms_output.put_line(v_tab(I));
    12     End Loop;
    13  End;
    14  /
    SMITH
    WARD
    JAMES
    PL/SQL procedure successfully completedRegards,
    Christian Balz

  • html:select : put each collection of country names in each user session?

    Hi,
    I have different <html:select> elements in my JSP. The options are filled with collections (country list, city list...).
    What is the best way to do for country for example? To retrieve all the country name from the database, put it in a arrayList for EACH user session. Or, put it in an application element?

    If it's not going to change for users, I'd store it in the application scope. No point to having multiple copies of the same information.

  • Onchange events when transforming select lists for EXTJS integration

    Hi,
    We have the folloiwng code that transforms select lists to extjs combo boxes
      var selectfield = Ext.query('select[class!="shuttle"][class!="multiselect"]');
      for (var r = 0; r < selectfield.length; r++) {
        //If there is an onchange event then don't convert as onchange is lost
        //This is used for cascading LOVs so we need to find a way of getting this to work
        if((selectfield[r].onchange == '' || selectfield[r].onchange == null) && ((r>0 && selectfield[r-1].onchange == null) || r==0) && selectfield[r].id != 'apexir_NUM_ROWS') {
          var newselect = new Ext.form.ComboBox({
            //hiddenId: selectfield[r].id,
            //hiddenName: selectfield[r].id,
            id: selectfield[r].id,
            typeAhead: true,
            triggerAction: 'all',
            transform: selectfield[r].id,
            width: selectfield[r].clientWidth+5,
            emptyText:'Please select...',
            forceSelection: true,
            maxHeight: 200,
            disabled: selectfield[r].disabled
      }The code does not convert select boxes that have onchange events as the code above seems to suggest they get lost when transforming. Does anyone know if that is the case, and if not how I amend the code to include the onchange events from the original select lists.
    Regards
    Paul

    Hi Vee,
    Thanks for pointing it out -- here at work the only version of IE I have is 6 and I assumed (as usually is the case) it was because of a bug in that specific version. However, I have the all-powerful, (allegedly) standards-compliant IE 9 at home and it behaved exactly the same way!
    So you cannot say this is due to an old, non-supported browser. Surely it fits in the bug category then? After all events should not be triggered at random...
    Thanks also for the suggestion to fix it. I didn't try it because, in the end, I found out that if I use onchange instead of onblur (in the text field) the problem doesn't occur! onblur would be better, but onchange works fine for what I need.
    Thanks
    Luis

  • Simple question - How do you make an onchange event occur in a select list

    Simple question - How do you make an onchange event occur in a select list to fire a process?
    Thanks

    1) Using ApEx Selec list on Submit Item.
    You will create a PL/SQL Process after Submit. -> Conditional Type Request = Expression1. -> Expression1 is the name of your Select List. Process Source - > Procedure you like. For example depending of your select List value you will add rows in different tables.
    2) Javascript This example will change a System parameter value when changed
    <select id="P3_SUBSYSTEM" onchange="location.href='f?p=101:3:2164422329953284::NO::P3_SUBSYSTEM:'+this.options[selectedIndex].value;" size="1" name="p_t21">

  • Unable to update chart after onchange event

    I have an OnChange event from my irpt containing a drop down box and an iSPCChart. I would like to have it when the user selects a number from the drop down list it passes the param and then refreshes the chart.   I know everything works on this except my update grid code because I click the refresh on the chart footer and the chart reflects what the user selects.  Can you please review this and let me know what I need to do to fix this?
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
    <!--
    Owner     Gregory M. Pyles Jr.
    Phone     x2689
    Date     02/21/2007
    Brief Description:
              This view allows users to see 6 mos worth of SK_FinalWeight data as an
              Ind Chart.  They have the ability to change the record count to see
              variability in Control Limits. 
    -->
            <title>SK_FinalWeights_Ind</title>
            <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
            <meta http-equiv="Expires" content="0" />
            <meta http-equiv="Cache-Control" content="no-cache" />
            <meta http-equiv="Pragma" content="no-cache" />
              <script type="text/javascript">
    where          tblSelection.Select List
    applet          ind_SK_FinalWeights
    type          onChange
    class          n/a
    method          onChange
    Comments     Ignores "-- Select --" and selects the value from the dropdown list. 
                   Then sets the param.5 (Fix Query: Select TOP [Param.5] ...From ...Where).
                   Updates the grid to reflect value selected.
    Examples     (1) alert(eval(obj<i>.value))
                   (2) alert(df.RecordCount.value)
                    function doSel(obj)
                              var df = document.frmMain;
                              for (i = 1; i < obj.length; i++)
                                        if (obj<i>.selected == true)
                                                  document.ind_SK_FinalWeights.getQueryObject().setParam(5,df.RecordCount.value);
                                                  document.ind_SK_FinalWeights.updateGrid(true);
    //------------------------>  Problem is on above line  <-----------------------------------
              </script>
        </head>
        <body>
    <!--          This body consist of two tables one of which is embedded in the first table.  "tblMain" sets the perimeter of the body. 
                        (1) The first row contains tblSelection drop down lists or ibrowsers can be placed here. 
                        (2) The second row contains the iSPCChart.
    -->
              <form name="frmMain">
                   <table name="tblMain" border="5">
                        <tr>
                             <table name="tblSelection" border="0">
                             <td>Record Count</td>
                                  <td>
                                       <select name="RecordCount" onchange="doSel(this)">
                                            <option> -- Select --</option>
                                            <option value="10">10</option>
                                            <option value="25">25</option>
                                            <option value="50" selected="selected">50</option>
                                            <option value="75">75</option>
                                            <option value="100">100</option>
                                            <option value="150">150</option>
                                            <option value="250">250</option>
                                            <option value="500">500</option>
                                       </select>
                                  </td>
                             </table>
                        </tr>
                        <tr>
                             <td>
                                  <applet name="ind_SK_FinalWeights" codebase="/Illuminator/Classes" code="iSPCChart" archive="illum8.zip" width="775" height="480" mayscript>
                                  <param name="DisplayTemplate" value="LincolnElectric/Dev/SK/dspSK_FinalWeights_Ind">
                                  <param name="QueryTemplate" value="LincolnElectric/Dev/SK/qrySK_FinalWeights_IndChart">
                                  <param name="ShowVerticalGrid" value="false">
                                  <param name="InitialUpdate" value="true">
                                  <param name="Param.1" value="{ID}">
                                  <param name="Param.2" value="{Line}">
                                  <param name="Param.3" value="{Operator}">
                                  <param name="Param.4" value="{OrderNo}">
                                  <param name="Param.5" value="50">
                                  </applet>
                             </td>
                        </tr>
                   </table>
              </form>
        </body>
    </html>

    You have an iSPCChart applet, but are using the iGrid's updateGrid(true) method.  Try changing the updateGrid(true) to updateChart(true).  That should work for you.

Maybe you are looking for