Assigning java script array to a variable in struts form class

Hi,
I am trying to send a javascript array of string from jsp to struts action form.
I have constructed a javascript array and assigned it to the form variable. But iam not able to access the variable in Action form. :( please let me know as to how i can send a string array in javascript to action form?.
JavaScript
var scriptarray = new Array();
// code for populating the array
document.MyForm.javaArray = scriptArray;
document.MyForm.action="MyAction.do?dispatch=handlerMethod";
document.MyForm.submit();

var input = document.createElement("input");
input.setAttribute("type", "hidden");
input.setAttribute("name", "bla..bla");
input.setAttribute("value", "bla..bla");And in addition to that.. Google is still alive

Similar Messages

  • Assigning java script array to java array..

    hi,
    can anyone tell me how to assign java script array to a java array which is bean.

    var input = document.createElement("input");
    input.setAttribute("type", "hidden");
    input.setAttribute("name", "bla..bla");
    input.setAttribute("value", "bla..bla");And in addition to that.. Google is still alive

  • How to populate a java script array from a bean.

    Hi all,
    I have a list "mdfProductNames" which is further comprising of two fields "subGroup" and "mdfProductName"
    The list is coming is a part of the form bean.(struts framework)
    Now i want to have the values of these two fields in two different java script arrays.
    i.e. Array x -> mdfProductName
    and Array y -> subGroup
    can someone give me any idea as to how to do this ?
    Thanks
    Edited by: Ramit on 17 Jul, 2008 9:53 AM

    hi,
    assuming u use jstl, u need to create javascript variable during html generation out of the values got from struts form bean. it could look like this:
    ------ .jsp file ----
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    <script type="text/javascript">
    var X = [];
    var Y = [];
    <c:forEach items="${formBeanName.mdfProductNames}" var="grpProdName">
    X.push( '${grpProdName.mdfProductName}' );
    Y.push( '${grpProdName.subGroup}' );
    </c:forEach>
    // here u already have the two arrays filled up with data
    </script>
    ------- end of .jsp file
    "formBeanName" is a name of a formbean u use to store the list of your beans
    rafal baton zaczynski
    http://baton.pop.e-wro.pl - tips and codes
    http://www.belysio.com - free mobile localization soft

  • Problem in assigning script array to Js variable

    There is a huge list(20,000) of cities that has to be put into a script array for the further use in the jsp page. so this script array is created once for all when the login is made for the application and stored a session variable. The sample of the script array is like-----
    <script>
    strArrCityName[17463]= "Zoar";
    strArrCityID[17463]= "10599";
    strArrCityStateID[17463]= "3";
    strArrCityName[17464]= "Zoarville";
    strArrCityID[17464]= "10600";
    strArrCityStateID[17464]= "3";
    </script>
    the entire stuff from <script>---</script>(uncluding the script tags is stored as a string in the session (strSessionCityArr))
    Now the porblem is i need to store this array into a js variable on jsp page load.
    I order to that i need to declare a js variable in jsp page
    ex::
    <html>
    <body>
    This is a sample jsp page created by <%= strUserName%>
    <script>
    var cityarry = "<%=session.getAttribute('strSessionCityArr')%>";
    </script>
    </body>
    </html>
    when i assign the array to the js variable , the <script> tag inside the string is conflicting with the <script> tag that of the jsp page.
    This throws the js error and the futher loading of the page is stopped.
    The reason i am storing it in the js variable is i will be painting the script array dyanamically on click of a button.
    Also in need both the script tags in the array is in other jsp pages i will painting the array on page load by using the out.println(strCityArray)
    I need a way in which this script array can be stored in js variable or any method by which i can directly get it from the session on button click
    Thanx in advance
    Manu

    i had tired constructing the script array using the JS but JS logic is always slower ...my point was not to do it all with JS code. My point was that unless you know how to properly define it as JS-only code, then it makes it hard to figure out how to break that up to Java generated code. It's clear to me that you don't have a very good grasp of what you're trying to do.
    The second point is, in some JSPs i need the <script> tags to be included in the array. No they don't. You can always put the <script> tags around what your Java variable includes if you are using that content in several places...
    <script><%= session.getAttribute('strSessionCityArr') %></script>

  • Java script is not working in custom tabular form

    hai all,
    i have changed my built in tabular form to custom tabular form.my java script is coding working fine in built in tabular form . But in my custom tabular form java script is not working ,since it is created as standard report(Display As).
    pls help me.
    with thanks and regards
    sivakumar.G

    Is the appostrophe function test(pthis) *'* present in your javascript code...
    If not can you post the same in apex.oracle.com and give the credential so that I can the why its not wroking
    Regards,
    Shijesh

  • By using Java scripting how  can  compare database value to Forms value?

    i develop portal form n want to compare field that is Issued quantity with available quantity through java scripting.please send me syntax with an example.
    problem:
    if issued quantity is greater than available Quantity then appear alert message
    Thanks,
    Sadaf

    this is the false forum for you. Try it in the database forum e.g.

  • How to assign java script variable to a hidden parameter in JSP?

    Hi All,
    I want to assign the variable in the Jscript to a hidden parameter in JSP page.
    <select name="sortingOption" class="sortingOptions" onchange="changeSortOption(this)">
    <c:forEach var="sortingOption" items="${sortingOptionList}">
    <c:set var="sortingOptionValue" value="${sortingOption}" target="java.lang.String"/>
    <c:choose>
    <c:when test="${sortingOptionValue == sortingOptionValueFromRequest}">
    <option value="${sortingOptionValue}" selected="selected">${sortingOptionValue}</option>
    <input type="hidden" name="srchType" value="none"/>
    </c:when>
    <c:otherwise>
    <option value="${sortingOptionValue}">${sortingOptionValue}</option>
    </c:otherwise>
    </c:choose>
    </c:forEach>
    </select>
    In changeSortOption script,they capture the value selected by the user and then they submit the form.I want to assign that value to a hidden parameter in JSP,can someone tell me how to do that?
    I dont have the Jscript code with me right now to post here.

    To the point: just by accessing/manipulating the HTML DOM using JS. Learn JS and HTML DOM. There are basic tutorials at w3schools.com. Besides, your code syntax is still invalid. The input hidden elemend doesn't belong in a select element. Learn HTML. There's a basic tutorial at w3schools.com as well.
    For future HTML/JS problems please consult the appropriate forums. This has not much to do with JSP. There are ones at webdeveloper.com.

  • Using Java Script to set cookies of a JSP form

    Hi,
    i m new to JSP as well as Javascript. i have a JSP which has two fields which are generated dynamically based on a no. of rows in a datasource, for eg. product datasource and the fields are productId,A. I also have one href link which opens another jsp. I want to set the cookie for productid when the user clicks on the link. i have written a javascript for setting the cookie. but i get a error saying the variable prodid object is null or not an object.The code is something like this,
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ taglib uri="/webapp/DataTags.tld" prefix="jbo" %>
    <HTML>
    <HEAD>
    <SCRIPT LANGUAGE="JavaScript">
    function setck(field) {
    for (i = 0; i < field.length; i++) {
    var pid = field.value;
    if ( pid != null && pid.length > 0)
    document.cookie = "CookieProductId" + i + "=" + pid;
    </script>
    </HEAD>
    <BODY>
    <center>
    <form name=myform >
    <jbo:ApplicationModule id="am" configname="FleetCardsBC.FleetCardsBCModule.FleetCardsBCModuleLocal" releasemode="Stateful" />
    <jbo:DataSource id="dsProd" appid="am" viewobject="FmmProductsView"/>
    <jbo:DataSource id="dsProdRes" appid="am" viewobject="FmmProductRestrictionsView"/>
    <table>
    <%int nRow = 0;%>
    <%
    nRow++;
    String s1 = null;
    Cookie[] cookies = request.getCookies();
    if (cookies != null)
    for (int i=0; i<cookies.length; i++)
    s1 = "name: "+cookies[i].getName()+ " value: "+cookies[i].getValue();
    out.println(s1);
    %>
    <jbo:RowsetIterate datasource="dsProd" >
    <tr><td>Product Id </td>
    <td><input type=text name="prodid" ></td>
    <td>A value </td>
    <td><input type=text name="A" ></td>
    <td>
    <a href="prodresdet.jsp" onfocus="this.value=setck(this.form.prodid)" >More Details</a>
    </td>
    </tr>
    </jbo:RowsetIterate>
    </table>
    </form>
    </center>
    </BODY>
    </HTML>
    Interestingly the cookies get set if instead of a link i use a button. Can someone tell what m i doing wrong, using a link.
    Thanks in advance
    Unmesh

    Doesn't work consistently.
    Here is the file modified with your script:
    https://www.box.com/s/09dzlu2kmiv7uziqef7j
    The way it should work is that, when you enter in a code, such as 1, a type appears on the right hand side- either C or S. A C is an automatic Fail and should appear in the pass/fail box after entering in the 1 under the code column. After the Fail appears, the script should be called and the subform should appear.
    Then, if you were to change the 1 under the code to a 6, the resulting type is an S which makes the pass/fail box turn to Pass. At this point, the subform should disappear.
    Does that make sense?

  • Assigning a jstl variable to java Script variable

    Hai All,
    I created one jsp page with java script with JSTL.
    I retrive arrayList from simple java bean in jsp page with help of JSTL .
    Now i want assign the ArrayList value through JSTL to Java Script Array.
    How to convert JSTL to Java Script.
    Please give me details asp.
    thanks ,
    Bala

    You can do this:
    <% request.setAttribute("x", "hello"); %>
    <c:out value="${x}"/>or if you want to go from JSTL to scriplet you can:
    <c:set var="testvar" value="hello" scope="request"/>
    <%= request.getAttribute("testvar") %>Both of these will output "hello"
    <c:set> defaults to the page scope, so you could substitute pageContext for request and get the same results (remove scope="request" first though).
    Karl

  • Getting tha java script error while calling OAF forms in ADF

    Hi ,
    I am trying to get/access the Oracle forms in ADF page.
    I am following http://static.commit-consulting.com/oraformsfaces developers guide for guidlines.
    while runnign my page getting the error in popup look like java script error.
    the pop up contente is :
    Failed to execute java script
    Check for JavaScript errors, if the Forms server is running and if your browser can download a javaScript from http://bdc6oracle001.gdnindia.com:8005/forms/frmservlet?config=OraFormsFaces
    http://bdc6oracle001.gdnindia.com:8005/forms/frmservlet?config=OraFormsFaces is my server EBS server where oracle forms exist.
    Please help me on this.
    Thanks,
    MadhavaReddy

    You're probably better off asking the OraFormsFaces people for help

  • Java Script - Java Applet Communication help me

    hi
    In my website i used html form to get the input from user. the user press the button the value are passed into java applet. The result will display in applet.
    my HTML coding for calling applet is
    <SCRIPT LANGUAGE="JavaScript"><!--
    var info = navigator.userAgent; var ns = false;
    var ie = (info.indexOf("MSIE") > 0 && info.indexOf("Win") > 0 && info.indexOf("Windows 3.1") < 0);
    //--></SCRIPT>
    <SCRIPT LANGUAGE="JavaScript"><!--
    if (_ie == true) document.writeln('<Center><OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="360" height="350" codebase="http://java.sun.com/products/plugin/1.1.2/jinstall-112-win32.cab#Vers ion=1,1,2,0"><NOEMBED><XMP>');
    else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.1.2" java_CODE = "suddhi.class" name=SuddhiPanchang width="360" height="350" pluginspage="http://java.sun.com/products/plugin/1.1.2/plugin-install.html"> <NOEMBED><XMP>');
    //--></SCRIPT>
    <APPLET mayscript="true" CODE = "suddhi.class" width="450" height="200" name=SuddhiPanchang ></XMP>
    <PARAM NAME = CODE VALUE = "suddhi.class" >
    </APPLET></NOEMBED></EMBED></OBJECT>
    java script code
    function calculate()
    if(checkEntries(document.forms[0]))return;
    with(Math){
    var day1 = floor(document.forms[0].Day1.value);
    var mon1 = floor(document.forms[0].Month1.selectedIndex) +1;
    var year1 = floor(document.forms[0].Year1.value);
    var day2 = floor(document.forms[0].Day2.value);
    var mon2 = floor(document.forms[0].Month2.selectedIndex) +1;
    var year2 = floor(document.forms[0].Year2.value);
    var tzone = abs(floor(document.forms[0].ZoneHour.value));
    tzone += floor(document.forms[0].ZoneMin.value)/60;
    if(Math.floor(document.forms[0].ZoneHour.value)<0.0) tzone *= -1;
    document.SuddhiPanchang.setStart(day1,mon1,year1,day2,mon2,year2,tzone);}
    i have error in the above line
    'document.SuddhiPanchang' is null or not an object
    url: http:\\rafik.cheyon.com\panch\msuddhi.htm check this
    please help me
    thanx

    You need to access it as document.formname.objectname

  • How to pass values to variables in WAD 7.0 using java script

    Hi.,
    My requirement is based on WAD 7.0.
    The sales value has to displayed in WAD using graph with various chart types.
    I have created variables for plant and material group in a query.
    I have created drop down box for plant with all plants in it, check box for material group and a Submit button in WAD in FORM tag of HTML coding.
    Once all the values are set in drop down box, checkbox and if the user clicks on submit button, the values has to captured by the variables for which I have created and the graph has to be aligned to the new values in variables.
    Kindly help me how to use java script to get the values from FORM and pass it to variables.
    Regards,
    Selva

    Hi Selva,
    You do not need to use Javascript for this. Instead you can achieve this by using API Commands in WAD 7.0.
    Please configure Action on the ButtonGroup webitem to use 'Commands'.
    ->Choose Command 'Set Variables Values / SET_VARIABLES_STATE' under Commands for Web Templates
    ->Set Display Variable Screen setting to OFF
    ->Choose Query Variable for Plant, Select Variable Type as 'Binding Type', Binding Type as 'Data Provider Selection', Data Provider as the one you have assigned to the Dropdown webitem, Characteristic as 0PLANT or as that assigned to the Dropdown webitem
    ->Repeat above steps for Query Variable Material Group
    Now when you make a selection from the Dropdown webitems, the Chart output will change accordingly. Let me know if this helps.
    --Priya

  • OBIEE variables in custom java script

    Hello all
    Can I use OBIEE variables like presentation and session variables in my custom java script code that I am writing in text view on a dashboard page. Is it possible to do that. please me soon if somebody knows the solution to do that.
    Thanks in Advance

    Hi john
    Thanks for reply, I am able to generate javascript using text view on a dashboard page.
    But I want to access OBIEE variables in javascript. How I can do that in narrative view. Can u explain me or give me any link.
    Thanks

  • How to access a JAVA Script variable in JSP Code

    How to access a JAVA Script variable in JSP Code. I have been unable todo this.
    Plz Suggest a way.
    Thanks
    Soumya

    try to do this code
    String s=request.getParameter("javascriptvariablename");

  • Column link - call java script & assign current report column value to item

    Hi,
    How to call java script and assing current report column value to item?
    I have a button column in the report to 'delete' the selected row.
    I want to first show dialog box with message 'Are you sure?'. If yes, process to delete
    will be executed, else no action.
    In order to fire JS, I used Column Link ->Target=URL.
    Problem: The alert is showing but I don't know how to pass selected row's primary
    key value to process (to delete selected row).
    I have a item which can be used to store selected primary key value but don't know how to assign the value
    when button pressed.
    Thanks in advance
    Dip

    Ok. The issue has been resolved by following way.
    PAGE PROCESS: delete_request
    begin
    delete xyz
    where id = :P8_id;
    commit;
    end;BUTTON URL:
    javascript: DelRec(null,'CREATE', 'f?p=&APP_ID.:8:&SESSION.:delete_request:NO::P8_id:#id#');Java Script:
    <script language="JavaScript1.1" type="text/javascript">
    function DelRec(msg, req, url){
    var confDel = msg;
    if(confDel ==null){
    confDel= confirm("Are you sure?");
    }else{
    confDel= confirm(msg);}
    if (confDel== true){
    redirect(url);           }
    </script>

Maybe you are looking for

  • How to connect a printer (wireles) to an existing mac-AE network from a PC?

    I have an airport extreme configured network that works perfectly well. That means that my mac connection to Internet is fine and I can print documents wireless without a problem from my mac. Recently I got a PC computer (OS Windows 7). Since the beg

  • HDMI mirroring no longer works on 10.8.4

    Tried to watch a movie on the big screen (two, actually) tonight on my MacBook Pro with Retina Display, but was surprised to learn this couldn't happen. I've owned the computer for roughly eight months now, and HDMI mirroring always worked without a

  • How do I get QuickTime/ITunes to read .mov files on Iphone 4?

    All software advises that it cannot read the .mov files from Iphone 4.   Photoshop advises that there is probably a codec missing.  Download from??  Would a video adapter correct the problem.......?

  • Business Package implementation on EP6 SP9

    Hi all i want to use the business package for sales and implement it in EP6 SP9. I got the package (BPSALESAN601_0-20000653.zip) from the market place. I uploded it to the server. But it is not working in EP side. Please help me...

  • Align Stroke To and Snap To are incompatible.

    This has always bothered me. I am wondering if anyone can defend ID's current stroking behaviour. If not it should be fixed. Changing the stroke alignment on an object changes the dimensions of the object. Does this ever make sense? If anyone begins