Passing values to javascript from database

hi friends,
I have to fetch values from the database and pass the values to the java script variable.
I tried this, but is not working. When i place the script inside the java, it isnt working. Iam passing value to this script variable as argument to a function. This is my code:
ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
while (rs.next())
for (int i = 1; i <= numberOfColumns; i++)
count=count+1;
if (i > 1)
columnValue = rs.getString(i);
%>
<script>
var hcbList = [<%=request.getParameter("columnValue")%>];
</script>     
<%           
System.out.println("");
st.close();
%>
Pls solve the problem. Its very urgent!
thanx

Keep this in mind: JSP is source generation software.
In other words JSP generates the HTML and/or Javascript that will be rendered on the browser. So What you need to do is keep the JSP and Javascript separate in your mental picture. You ask yourself, "what would the finished Javascript code look like that would give me the results?" Then you apply JSP as a template to fill in the blanks. In your example you want a list or an array of values in your Javascript. I don't use Javascript to often but from memory I belive an array in Javascript is something like this:
<script>
var hcbList = {"val1", "val2, "valx"};
</script>That's what the finished Javascript would look like. Now you apply JSP as a template.
<!-- This is the fill-in-the-blank template
<script>
var hcbList = {<%=insertArrayHere%>};
</script>Now you fill in the blanks
//insertArrayHere is your blank
String insertArrayHere = "";
//iterate over the collection and build a string that represents the JS array
for(int i = 1; i <= numberOfColumns; i++)
   //wrap each value with quotes if it is to be a JS string
   insertArrayHere += "\"" + rs.getString(i) + "\"" + ","; //terminate with a comma
//trim the last comma off the array guts
insertArrayHere = insertArrayHere.substring(0, insertArrayHere.length() - 1); Now I'm sure that's not exactly what you want because it looks like you got some crazyness going on in your logic. I don't know how you can query the using values from the database. Anyhow it poses as a good example of how to apply the concept of the two technologies. (Also, why are you doing a System.out from JSP? You should be calling log() if you want console output.) The whole idea is that JSP can NOT talk directly to Javascript. It can only generate Javascript dynamically before it is received by the browser.

Similar Messages

  • How to passing value into Captivate from html?

    How to passing value into Captivate from html?
    Or
    How to communicate between objects in one slides?

    Hi czhao0378 and welcome to the forums!
    Captivate does not natively allow you to communicate your own
    data, either internally or externally. The only way to make this
    happen is to create your own functionality, either via custom-built
    Flash objects or JavaScript code executed in the browser or a
    combination of both.
    The only example I've seen of any "data passing" inside
    Captivate is a custom text input/output solution that was posted on
    the Captivate Developer Exchange:
    http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&loc=en_us&extid=1253 021
    This solution consists of an input box that takes information
    from the user on one slide and a second box that displays that
    information on another slide. The functionality was built in Flash
    and is embedded in Captivate as a Flash "animation". Unfortunately,
    since this is a custom functionality, the information is not
    included in the user completion results Captivate can pass to a
    Learning Management System.
    Since the solution mentioned above relies on a Flash
    Actionscript variable to hold the information that is displayed,
    you can also pass the information from HTML to Captivate using the
    "SetVariable" command in JavaScript. This would at least allow you
    to display your own HTML-based data inside Captivate.
    Beyond that, I'm not aware of any other way to gather and
    pass data in Captivate.

  • How to pass a value to javascript from flash using externalinterface

    hi,
    i'm currently trying to call a javascript function and pass values to it. but i'm not really familiar in using the addcallback since i only tested on calling a function from flash without passing anything to the function.
    Basically, i'm going to retrieve the values of a node from xml.
    and then i will assign those values to a variable in flash.
    now what i'm going to do next is pass this value to a javascript parameter..is it done using externalinterface?
    Could anyone give me an example.
    I just need to throw the value to the javascript function parameter and no return values to the actionscript.
    The event is that whenever an image is click, the corresponding value for each image is passed to the javascript function.
    here is my unfinished script.
    function imageClicked(e:Event):void {
        for each (var imageURL:XML in xml.images.link_to)
            ExternalInterface.call("TestButton",imageURL);
    thanks so much in advance.

    first, it seems that the 'TestButton' funciton in JS will be called several times when an image is clicked - for each loop in the 'for each' loop you wrote.
    second, in order to test the communication between AS and JS, try starting with something simple, like -
    ExternalInterface.call('alert', 'OK');
    if this doesn't work try tracing the ExteranlInterface.available property/
    if it does work, place an alert within the 'TestButton' in the JS code, to see its actually being called.
    and so forth...
    good luck,
    eRez

  • Pass arguments to javascript from plug in...

    Hi,
    I m using InDesign CS3 on MAC OS...
    I have a plugin calling a javascript. I need to pass a string value from the plug in to the script...
    I found that there is a parameter in the method RunFile in IScriptRunner.h for this purpose... But i don kno how to use this...
    virtual ErrorCode    RunFile(const IDFile& idFile, IScriptEventData* data,  bool16 showErrorAlert = kTrue, bool16 invokeDebugger = kFalse) = 0;
    where,
    @param data is used to pass arguments and return the result IN/OUT
    What does this  IScriptEventData* data carry???
    How to pass a string value as argument to javascript from plugin code and how to retrieve and use it there...
    Is there any sample code for this?
    Someone pls guide me...
    Thank you.

    Are there other command line options with extendscript, like compile to jsxbin etc.. Where is this documented?
    UDevp wrote:
    I used the below command to run script from command prompt, I'm able to run the script but not able to pass arguments to the script.
       "C:\Program Files\Adobe\Adobe Utilities\ExtendScript Toolkit CS4\ExtendScript Toolkit.exe" -run "C:\Program Files\Adobe\Adobe InDesign CS4\Scripts\test.jsx"
    Any suggestion would be helpful..
    It may be possible to edit prefs file with command line and to check file in script.

  • Passing values to Javascripts/ write to text file

    Hi,
    I m new to InDesign Programming. I m using InDesign CS3 on MAC OS...
    Is it possible to pass values to a javascript through plugin code?
    I have a dialog with textboxes in it, On clicking ok button a script is called which uses these text box values for processing. Is this possible or is this the only way: to write them into a text file and read the textfile in script....
    Someone Pls guide me...

    Are you looking for this:<br /><br />in C++ :<br />Utils<IScriptArgs>()->Set(yourkeyStr ,yourvalueStr );<br /><br />in JavaScript: <br />if(app.scriptArgs.isDefined(yourkeyStr)) {<br />     var yourvalueStr = app.scriptArgs.get(yourkeyStr)<br />}<br /><br />HTH,<br />Kamran

  • How to pass parameters to javascript from HTMLB Button Click

    Hi Experts,
    I am using a HTMLB Button, I need to pass parameters to JavaScript onClientClick.
    Whether we can pass parameters to javascript function from HTMLB button.
    I tried to pass parameters to javascript in onClientClick, but on load of the page it is saying that its a Syntax error.
    This is the code that i have created Script
    Note: The parameters and the Button are dynamically created. Also there are n Numbers of buttons created.
    Please help me in this regard to solve the issue. If there are any error in syntax please let me know.
    Thanks & Regards,
    Palani

    Rather than using SQL loader, you could just use similar syntax in an external table definition. It both cases, the file may need to be at the OS level.
    http://www.psoug.org/reference/externaltab.html
    If your file is stored in an Apex table's clob column, you can just loop through the individual lines (but then need to parse the lines yourself). See clob2line here http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:285215954607#388438800346703098
    Or you can dump the clob to the OS first (using utl_file or dbms_lob), and then read it back using external table, taking advantage of your control file definition. sqlloader has the disadvantage of needing user/pass usually.
    http://www.psoug.org/reference/dbms_lob.html
    http://www.psoug.org/reference/utl_file.html

  • Passing values to Jframe from JApplet

    Hi All,
    i need to open a frame when someone clicks on some particular part of an applet. also, i need to pass some values to that frame based on the region selected.
    Previusly i m doing it through showDocument method which calls a JSP which in turn calls the applet that i m trying to change as a frame now.
    Help please.
    Liza

    just to make things more clearer... i was passing values as querystring to JSP which passes them to an applet through parameter tags.
    Liza

  • Passing Values to and from a Javascript rule - Agentry

    Hi;
    I am working on determining the first day and last day of the week using a javascript rule, so this can be in turn passed to an Agentry date and time property. When I debug in the ATE, it seems my javascript rule is always returning zero. What could I be missing, please see below the rule implementation. I am using this rule on a transaction property, under the "Initial Value" attribute - before data entry:
    What could my rule be missing, How could I implement this correctly?
    Much appreciated!
    Sizo Ndlovu
    Tags edited by: Michael Appleby

    Hi Stephen;
    I have done as you advised, but I seem to be still getting a zero returned, please see below:
    The Javascript method return variable (curUnixTime -: as shown on the first screenshot), is it automatically returned onto the WeekEnd property or there is extra code/steps that I need to add?
    Thanks and Regards;
    Sizo Ndlovu

  • Values not read from database table.

    Hi experts,
    I have an issue reading values from the database table. In my custom table I have a KUNAG field. The Sold-to partyis a 10 character field. I have saved a record with KUNAG = '0000694012'.
    But when i read the values in a program using KUNAG= '0000694012' no records are read. Kindly help
    Regards,
    Girish

    Hi,
         This field has conversion exit.
         Pass the appropriate value after converting.
    Regards,
    Srini.

  • Passing values to OnDemandProcess from Select Statement on Reports Page

    I think I'm just missing some of the proper syntax, Can somebody please help me.
    As I've come to understand this process of passing the values,
    I recognize it as (3) steps.
    1. Referencing the "javascript" in the Select Statement of the Reports Page.
    2. Including the "javascript" in the Page Header region.
    3. Defining the Process as an OnDemand Application Process.
    My problem is:
    a. I can't seem to get the Value passed to the Application Process.
    b. I don't know how to reference the Value passed once I get it passed.
    Here's what I've got done so far:
    1. (The Select Statement)
       onClick="javascript:ORDER_CONNECT_SEQUENCE('||ID||')
    {code}
    2. (The javascript)
    {code}
    function ORDER_CONNECT_SEQUENCE('+ID+')
    var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=ORDER_CONNECT_SEQUENCE',0);
    get.add('+ID+');
    gReturn = get.get('+ID+');
    {code}
    3. (The Application Process)
    {code}
       BEGIN
       Select '+ID+' into THIS_CIRCUIT from dual;
    {code}
    I Know that the Application Process is being referenced and that the OnClick routine is working properly,
    because if I plug a Value into the Application Process, instead of using '+ID+',
    Then I get all of my desired results.
    Any help you can give me here is greatly appreciated.
    Thanks- Gary                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Dimitri, Thanks for your efforts here, but its still not working for me.
    Here's what I understand from your suggestions:
    1. (changes to the javascipt)
       a. replace function ORDER_CONNECT_SEQUENCE('+ID+')
           with
           function ORDER_CONNECT_SEQUENCE(pId)
       b. replace get.add('+ID+')
           with
           get.addParam('x01',pId)
       c. replace getReturn = get.get('+ID+')
          with
          getReturn = get.get()
          get = null2. (chages to the Application Process)
       a. add l_value varchar2(4000) to my list of declarations
       b. add l_value := wwv_flow.g_x01 below the begin statement
       c. I guess then I would reference the l_value like this:
           Select l_value into THIS_CIRCUIT from dual* Also, You didn't mention any changes in my Select statement in the Reports region of the page.
    FYI.
      onClick="javascript:ORDER_CONNECT_SEQUENCE('||ID||')
    {code}
      The 'ID' which I'm referencing here is an ID from the table which I'm querying.
    Am I misunderstanding you somewhere?
    Thanks- gary                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Passing values in table from one component to another component in gp

    hai all,
      I have a table with 5 rows in a view in component1.I need to pass the values in the table from component1 to table in component2.Plz help me with coding of interface controller of both component.
    Thanks in advance
    regards
    Sharanya.R

    Hi,
    Here more than coding its mapping of your components are important to transfer data
    Ex:
    You need to have a public part that exposes the node which is bound to the table in COMPA.
    Then in COMPB you need to make COMPA as used COMP.
    Then you need to map the contexts between them.
    Once this is done . You will need to code if you want to iterate through the elements.
    Following Docs will help you get  a  clear understanding
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f727d100-0801-0010-4cbd-b0ad5c161945
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e1f4df00-0801-0010-6298-8fdf667bbd0f
    Regards
    Ayyapparaj

  • Passing values to jsp from html..

    Hi all,
    I have a jsp containing a selection list and need to pass the value to the java segment of the jsp. When reserching this, I've found some info where an html page was created, an initial jsp was saving the info (or bean was used) and then a third jsp displayed the data (using buttons). This is too many steps and I'm needing a way for the same jsp to display containing the selected option (simulating a refresh with the post when the drop down list is used). Is redirecting while setting and getting attributes all at once feasible/possible or is there a better direction or work around for this?
    Thanks in advance,
    Geoff-

    I would think submitting the page to itself, and setting hidden fields to signal that it is a resubmission, may be the way to go. If the new information being displayed is minimal, JavaScript may also work, by setting up an empty <div> or <span> and setting the innerHTML or innerText properties. The advantage of the JavaScript solution is it would be quicker, having the client do all the processing, but it also browser dependant.

  • Passing values to FM froma selection screen

    Hi Guys,
    I have a selection screen in which i have 'From' and 'To' input fields.Also using multiple select button i can select discrete values.In the function module they have a table type in the import param.
    Is it possible to send the  values within the range plus the discrete values selected? If yes, then please help.
    Thanks,
    tubai.

    Hi,
    You can below code:
      DATA: rt_ranges TYPE REF TO data.
      FIELD-SYMBOLS:  <fs_select> TYPE table,
                                <fs_wa>  TYPE ANY,
                                <fs_wa1> TYPE ANY.
      DATA: lt_select  TYPE TABLE OF rsdsselopt,
                wa_sel_opt TYPE rsdsselopt.
    Retrieve the data from the select option
      rt_ranges = wd_this->w_handler->get_range_table_of_sel_field(
                               i_id = 'SELECT' ).
    Assign it to a field symbol
      ASSIGN rt_ranges->* TO <fs_select>.
      IF NOT <fs_select> IS INITIAL.
        LOOP AT <fs_select> ASSIGNING <fs_wa>.
          ASSIGN COMPONENT 'SIGN' OF STRUCTURE <fs_wa> TO <fs_wa1>.
          lwa_sel_opt-sign = <fs_wa1>.
          ASSIGN COMPONENT 'OPTION' OF STRUCTURE <fs_wa> TO <fs_wa1>.
          lwa_sel_opt-option = <fs_wa1>.
          ASSIGN COMPONENT 'LOW' OF STRUCTURE <fs_wa> TO <fs_wa1>.
          lwa_sel_opt-low = <fs_wa1>.
          ASSIGN COMPONENT 'HIGH' OF STRUCTURE <fs_wa> TO <fs_wa1>.
          lwa_sel_opt-high = <fs_wa1>.
          APPEND lwa_sel_opt TO lt_select.
        ENDLOOP.
      ENDIF.
    You then pass lt_select to your FM.
    Regards,
    Priya

  • Passing values to FG from program

    Hi all
           Please help me to sort this problem.I have to call a screen in the Function group from a report  program so I am using below code to call it.
    clear bdcdata_wa.
      bdcdata_wa-program = 'SAPLZSECURITIES'.
      bdcdata_wa-dynpro = '0300'. "where 300 normal screen
      bdcdata_wa-dynbegin = 'X'.
      append bdcdata_wa to bdcdata_tab.
      call transaction 'ZDOCS_SECURITIES' using bdcdata_tab.
    Now I have to access the values from the program in FG screen after calling the screen.So I used below code but it is not working.Please help me to sort it out.
    assign ('(ZCML_DOCS_SECURITIES)I_VDARL') to <fs_vdarl>."I_VDARL Structure
          if sy-subrc = 0.
            move <fs_vdarl> to i_vdarl.
          endif.
    Thank You.
    Regards
    Giri

    That would work if it's an include/form, and you read data from the main program. But I do not know if it can be used with a call transaction. Maybe the problem is that it is not the same LUW... But I am not sure.
    I can't see anyting wrong with the code itself.
    When debugging, is the field symbol <fs_vdarl> assigned?
    Can you use an export to memory instead?

  • Type in value and retrieve from database

    Hi,
    I have a database of clients and to keep it up to date, we will be sending out an email asking them to confirm if they're details are correct and up to date.
    In that email will be a link to a webpage where they can confirm their details are up to date. They will have to type in their email address which will then retrieve their information to update or confirm they are correct.
    I have no trouble updating. I usually list the data and then click on the one that needs updating.
    I'm having trouble retrieving the information after the user has typed in their email address.
    Here is my code so far - at the moment I have listed the data in a table with an "update" link next to each row that allows me to update.
    Where would I put the text field where the user can type in their email? I've tried different ways but was unsuccessful.
    Hope you can help
    Thanks
    <%
    strSQL = "SELECT * FROM emails"
    rsEmail.Open strSQL, conn
    %>
    <html>
    <head><title>All</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link href="layout.css" rel="stylesheet" type="text/css">
    </head>
    <body>
    <div id="wrapper">
      <p>  </p>
      <div id="view">
      <div class="insert"><a href="insertform.html">Insert</a></div>
      </div>
      <table width="1100" cellpadding="5">
        <tr>
          <td width="53">ID</td>
          <td width="300">firstname</td>
          <td width="378">lastname</td>
          <td width="121">email</td>
          <td width="92">Update</td>
          <td width="92">Delete</td>
        </tr>
      </table>
      <table width="1100" cellpadding="5">
        <%
       Do While not rsEmail.EOF
    %>
        <tr><td width="53"><% Response.Write rsEmail("id") %></td>
          <td width="294"><% Response.Write rsEmail("firstname") %></td>
          <td width="374"><% Response.Write rsEmail("lastname") %></td>
          <td width="119"><% Response.Write rsEmail("email") %></td>
          <td width="91"><%  Response.Write ("<a href=""update_form.asp?ID=" & rsEmail("ID") & """>")%>Update<%Response.Write ("</a>") %></td>
        </tr>
        <%
    rsEmail.MoveNext
    Loop
    'Reset server objects
    rsEmail.Close
    Set rsEmail = Nothing
    Set conn = Nothing
    %>
      </table>
    </div>
    </body>
    </html>

    This 'tutorial' is flawed and needs work. Use with care.
    1 - Upload the file correctly. This is NOT an example of how to upload a file from a web page. You need method="post" and enctype="multipart/form-data". Then in the servlet doing the file retrieval you need to get the input stream from the request. Using a library like the jakarta commons File Upload is recommended.
    2 - Database connection should not be done in a JSP. 'nuff said.
    3 - In fact scriptlet code in a JSP is a bad approach in general. avoid.
    4 - A better approach would be to use an ImageServlet as exampled, and just have img tag reference that servlet directly.
    While I applaud the intentions behind wanting to share the code, the code shows several basic design flaws. I think it is a better example of what NOT to do rather than the intended how-to.
    Thats my 2 cents.
    evnafets

Maybe you are looking for

  • USB2DVI adaptor window refresh problem

    Good evening together, I am experiencing strange issue with the Lenovo USB2DVI adaptor connected to a 24" Lenovo monitor. The screen is recognised without problems and displays the running programs without problems. There are 2 so far identified exce

  • Strange assembly reference error...wrong version?

    Post Author: redwing19 CA Forum: General I'm using Crystal Reports with Visual Studio 2005 and I get an error when I try to run my app that says: "The type initializer for 'CrystalDecisions.ReportSource.ReportSourceFactory' threw an exception." with

  • How do I get rid of safari sidebar.  iPad is running 8.0.2.

    HHow do

  • Do notes disappear after a certain time?

    The earliest entry in the Notes app has disappeared. Do they get deleted after a certain time or if I have inadvertantly deleted it can i get it back from icloud somehow?

  • Do IPhone 6 screens crack easily?

    I have an IPhone 6 with a cracked screen.  The phone still works, and I don't want to be without it and have to mail it in for repair.  Can't get through to my local pole store:  Does anyone know if local Apple support centers are fixing cracked IPho