Creating dynamic textbox in JSP

I am trying to create dynamic textbox.when i run this below JS ,I am getting two boxes only and then i nothing getting it displayed.The problem comes in the inner for loop.
function DynamicBox(val)
                    alert("helloooo");
                     var d =document.getElementById("bottom");
                     d.innerHTML = '<table cellpadding="10">';
                    for(i=0;i<val;i++)
                            d.innerHTML += '<tr><td><INPUT type="text" name="week'+i+'" size=8 >  </td><td><INPUT type="text" name="deliverable'+i+'" size=30>  </td>';
                          for(j=1;j<=<%=parameter.length%>;j++)
                                   <% int m=0;%>
                                  d.innerHTML+='<td><INPUT type="text" name="'+<%=parameter[m]%>+i+'" size=10></td>';
                                  <% m++; %>
                             d.innerHTML +='</tr><br />';
                        d.innerHTML+='</table>';
                }In the above code,val is the number of rows to be created.Bottom is the id of the <div> tag.parametr is a String array.The values are coming from database.

move the <% int m=0;%> out of the loop.. You have place it in the loop, causing it to be initialize to be 0 each time the looping occurs.
Place <% int m=0;%> below the line: d.innerHTML = '<table cellpadding="10">'

Similar Messages

  • How to create dynamic Textbox in JSP

    I created dynamic Textboxes using javascript in JSP.But i want to give every textbox a unique name..But I dont know how to give unique name to all the textbox which are created dynamically.....Can u help me Please.............
    <script code="text/javascript">
    function dynam(val)
    var d= document.getElementById("Bottom");
    d.innerHTML='<table>';
    for(i=1;i<=val;i++)
    d.innerHTML += '<tr><td>Parameter</td><td><INPUT type="text" name="week"'+i+'size = 15></td>';
    d.innerHTML +='</table>' ;
    </script>in the above code."val" is the integer value passed while calling this function. "Bottom" is the id of <DIV> tag in my JSP page.
    My problem is : when i creating a text box. the Unique name of the textbox in not getting generated.All the text bok has the same name as "week",but i want the name to be as week1,week2,week3,.....etc
    Edited by: AnilTcs on Jan 21, 2009 1:31 AM

    Try this:
    d.innerHTML += '<tr><td>Parameter</td><td><INPUT type="text" name="week '+i+' " size = 15></td>';I have just changed the quotes around week. Hope this helps.

  • Create Dynamic TextBox in LIghtSwitch

    Hi Team,
    i am developing HTML client LightSwitch Application
    My doubt is i need to create textboxes in the screen which will not be bound to any entity. I want to display the aggregate value from the screen. 
    Department Name - Filter      
    Actual Effort Sum - TexField - 25 
    Planned Effort Sum
    - TexField - 30     
    Effort Variance - TexField - 5
    Resource Name
    Department
    Actual Effort
    Planned Effort
    Srikanth
    ABC
    10
    15
    Ashok
    ABC
    15
    15
    as shown in the above screen model (Since i cannot able to upload my browse screen snapshot)which is screen for the entity ResourceEfforts and i
    have one filter (Department Name) which is not optional, so when use enters the department it will display all the resource names with their efforts in the browse screen (from the ResourceEfforts entity)
    those who are comes under that particular department. 
    My Requirement is, i
    want to show the aggregate value from the screen values (sum of Actual Effort, sum of Planned Effort and total Effort variance) in the dynamic text fields for the entered department value in the filter. 
    i have been thinking of using Linq Query to evaluate the value but i need to pass the entered department filter value in the 'where' condition
    of the linq query.  
    so anyone please tell me if you have suggestions for this scenario, it will be really helpful.
    Thanks,
    Srikanth Anantharaman

    Hello Srikanth,
    You may find the following link helpful:
    http://lightswitchhelpwebsite.com/Blog/tabid/61/EntryId/1207/HUY-Volume-III-ndash-Popups-Dirty-Visual-Collections-and-Using-Prototypes-To-Calculate-Child-Collections.aspx
    Scroll down the page until you see a section called Using Prototypes To Calculate Child Records.
    Another way is to bind your Filter property to the parameter of the dataset on that screen.  Click on Edit Query on the right hand side of the Table name, then add a new filter at the top saying something like  Where Department equals
    , then pick Parameter from the third dropdown and Add new from the final dropdown.
    This will create a new Parameter at the bottom of the query screen called "Department" (although you can rename it by clicking on its name, if you like.)   If you want to see all Departments if a specific one is not entered, check the
    box marked "Is Optional".
    Click the link to go back to your screen in the upper left.  Select your table again, and now you'll see a new section at the bottom called Query Parameters, and your new parameter should be there. Click on your new parameter, and in the Properties
    window, set the Parameter Binding to the name of the screen property you created, DepartmentName, or whatever its name is.  Test your program by hitting F5 or clicking Start, and you should see that the table does change whenever you type something into
    your Department Name - Filter box.
    Once that works, the next thing to do is go to the PostRender event for your DepartmentName box and add a contentItem.dataBind so that you can calculate the display fields immediately when someone puts a department into the box.  Something like:
    myapp.DepartmentScreen.DepartmentName.PostRender(element,contentItem) {
       contentItem.dataBind("value",function(newValue) {
          if(newValue != undefined && newValue != null) {
             contentItem.screen.getDepartmentTableItems().then(function() {
                var actualSum = 0;
                var plannedSum = 0;
                contentItem.screen.DepartmentTableItems.foreach(function(item) {
                   actualSum += item.ActualEffort;
                   plannedEffortSum += item.PlannedEffort;
                screen.ActualEffortSum = actualSum;
                screen.PlannedEffortSum = plannedSum;
                screen.EffortVariance = plannedSum - actualSum;

  • Dynamic Textboxes in JSP using struts

    Hi all
    I'm using JSP and Struts framework. I have two buttons Add row and delete row.(not submit buttons) on click i need to either generate or delete a row of textboxes. I able to do the same using javascript but the tag in that case is <input..>(normal HTML) and not <html:text> tag of struts.. Can i use the struts tag in jsp?? I tried but err... So any suggestions?
    A sample code would be of great help.. Im still a beginner in this ocean of Java!
    cya

    If the add/delete row buttons run in javascript, then you have to use the standard <input> tags.
    The struts <html:text> tag is a JSP tag that just generates an <input> at the end of the day anyway (filling in the attributes automatically though)
    As long as you name the controls consistent with what would have been produced by the struts tag, it should work perfectly well.

  • How to create dynamic tables in jsp page

    Hi,
    Iwant to create a table with 8 rows.each row will have two select boxes and one text box.besides i have add button.intially the screen shows only one row.if user clicks on add button then another row is added.like this upto 8 rows.
    how can solve this problem..
    regards,

    Hi I am not a big programmer but i can suggest a method to u
    try something like this..
    this could be quite adjusted in html page itself.....
    <html>
    <head>
    <script language="javascript">
    var count=1
    fucntion addRow(){
    if(count<8){
    count=count+1
    row.innerHTML=row.innerHTML+"<tr><td><input type='text' name="+count+"></td><td><input type='button' onclick=addRow() value='Add' name='add'></td></tr>"
    else if(count==8){
    row.innerHTML=row.innerHTML+"<tr><td><input type='text' name="+count+"></td><td></td></tr>"
    </script >
    </head>
    <body>
    <form action='Myservlet" method='post'>
    <table>
    <div name='row' name='row'><tr><td><input type='text' name=1></td><td><input type='button' onclick=addRow() value='Add' name='add'></td></tr></div>
    </table>
    </form>
    </body>
    </html>
    I believe it could be quite adjusted @ client side itself.... as per your description...

  • Can't create dynamic html elements with jsp????? important

    Hi All,
    I am having problem creating dynamic html elements with jsp tags, i have tried to use EL and java scriplet, both of them don't work.
    i am trying to create dynamic menu in my "rightMenu.jspf", based on, if user has logged in or not.
    some like this!
    <jsp:if test ="${validUser == null}">
    some simple text menu here
    </jsp:if>
    but it is not working. it simply loading all and images with in statement, regardless of whether user has logged in or not. i think some how if statement is not working properly.
    "validUser" is a session bean, which is not creating at this point, it will created when user will log in successfully. and also this session bean does not exist at the page, where i am trying to check that .
    Is there any way to create dynamic values in jsp. It is really important, is there any body who help me in this matter. i would be really grateful.
    zaman

    hi jaspre,
    thanks for replying me. you know what, is it not something wrong with web.xml file. i remember once, i deleted some from there, a property with "*.jsp". i can't remember what exactly was it though.
    all if statements works on files ending with extension ".jsp" but don't work only on with extension ".jspf". there must be to do with this.
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <servlet>
    <servlet-name>ValidateServlet</servlet-name>
    <servlet-class>ValidateServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>ValidateServlet</servlet-name>
    <url-pattern>/ValidateServlet</url-pattern>
    </servlet-mapping>
    <servlet>
    <servlet-name>dwr-invoker</servlet-name>
    <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
    <init-param>
    <param-name>debug</param-name>
    <param-value>true</param-value>
    </init-param>
    <init-param>
    <param-name>pollAndCometEnabled</param-name>
    <param-value>true</param-value>
    </init-param>
    </servlet>
    <servlet-mapping>
    <servlet-name>dwr-invoker</servlet-name>
    <url-pattern>/dwr/*</url-pattern>
    </servlet-mapping>
    <session-config>
    <session-timeout>
    30
    </session-timeout>
    </session-config>
    <welcome-file-list>
         <welcome-file>
    main.jsp
    </welcome-file>
    </welcome-file-list>
    </web-app>
    if any one can figure it out. i would be grateful.
    zaman

  • How can we create dynamic pie chart in jsp

    hi im a new jsp programmer and i just want to know how can i create dynamic pie chart in jsp

    http://sourceforge.net/projects/jfreechart
    - Saish

  • How to create two level dynamic list using JSP , Java Script and Oracle

    I am new in JSP. And i am facing problem in creating two level dynamic list using JSP ,Java Script where the listdata will come from Oracle 10g express edition database. Is there any easy way in JSP that is available on in ASP.NET.
    Plz response with details.

    1) Learn JDBC API [http://java.sun.com/docs/books/tutorial/jdbc/index.html].
    2) Create DAO class which contains JDBC code and do all SQL queries and returns or takes ID's or DTO objects.
    3) Learn Servlet API [http://java.sun.com/javaee/5/docs/tutorial/doc/].
    4) Create Servlet class which calls the DAO class, gets the list of DTO's as result, puts it as a request attribute and forwards the request to a JSP page.
    5) Learn JSP and JSTL [http://java.sun.com/javaee/5/docs/tutorial/doc/]. Also learn HTML if you even don't know it.
    6) Create JSP page which uses the JSTL c:forEach tag to access the list of DTO's and iterate over it and prints a HTML list out.
    You don't need Javascript for this.

  • Create dynamic image, dump on server someplace and reference in JSP?

    I was thinking about creating dynamic images and referencing them on a JSP
              (creating them is ok). I'm sure this is a pretty standard thing, but I
              don't know how to do it. Any ideas? I tried doing a search on the BEA
              support site (nice changes :>) but nothing very accurate came up.
              Thanks.
              

    Assign an ID (e.g. 1234) to the uploaded file. You should abstract the store
              so that it will work on the file system or in the database.
              The JSP will include an image ref to that ID, e.g.
              http://www.myco.com/myapp/imageservlet?id=1234
              The image servlet will retrieve and stream the image. It has to set content
              type etc. You should also verify that the current user has access to the
              requested image if security/privacy is an issue.
              Peace,
              Cameron Purdy
              Tangosol, Inc.
              http://www.tangosol.com/coherence.jsp
              Tangosol Coherence: Clustered Replicated Cache for Weblogic
              "PHenry" <[RemoveBeforeSending][email protected]> wrote in message
              news:[email protected]...
              > Howdy. I just thought of something. If the img is coming across via the
              > stream, how do you reference it in the html/jsp file? I just thought
              about
              > that now as I was getting a cup of coffee. (I need to cut back! :>)
              >
              > Thanks.
              >
              >
              >
              >
              > "Cameron Purdy" <[email protected]> wrote in message
              > news:[email protected]...
              > > If you write it to a file, you are writing it to an OutputStream, right?
              > >
              > > Instead, just write it to the OutputStream that comes from the
              HttpRequest
              > > object. For example:
              > >
              > > <img src="http://www.mysite.com/myapp/my.jsp?name=whatever">
              > >
              > > That would hit your JSP (it would be better to use a Servlet in this
              case
              > > though), and you would stream back the image.
              > >
              > > Peace,
              > >
              > > Cameron Purdy
              > > Tangosol, Inc.
              > > http://www.tangosol.com/coherence.jsp
              > > Tangosol Coherence: Clustered Replicated Cache for Weblogic
              > >
              > >
              > > "PHenry" <[RemoveBeforeSending][email protected]> wrote in message
              > > news:[email protected]...
              > > > Interesting. I'm still a bit new to this stuff. Do you have/know
              where
              > > to
              > > > find some examples?
              > >
              > >
              > >
              >
              >
              

  • Dynamic textbox through the Back button

    I have created a dynamic textbox in a JSP using Javascript.
    When I submit the form in this JSP, the data's validated & a confirmation message is displayed.
    On this confirmation message, when the Back button is clicked, I get the original form with the data entered for all the fields except for the dynamic textbox, because there is no dynamic textbox!
    The textbox is to be displayed only when a condn is fulfilled. This is coded in a Javascript fn that gets called only when a particular value in the listbox of the form is selected.
    How do I display the textbox when the Back button's clicked?

    Thx for trying to help.
    Here's the source code:
    <script language="JavaScript">
    <!--
    function textBox(areaName, submitted)
    var spanTxtID = document.getElementById('insertTxtSpan');
    var areaNameText=document.createElement('input');
    areaNameText.setAttribute('type', 'text');
    areaNameText.setAttribute('name', 'areaNameText');
    areaNameText.setAttribute('maxLength', 20);
    areaNameText.setAttribute('size', '20');
    //areaNameText.setAttribute('value', 'Khar');
    //alert(areaName.value)
    if(areaName.value=="Other")
    submitted=false;
    while(spanTxtID.hasChildNodes()) spanTxtID.removeChild(spanTxtID.lastChild);
    spanTxtID.appendChild(areaNameText);
    else { submitted=false; while(spanTxtID.hasChildNodes()) spanTxtID.removeChild(spanTxtID.lastChild); }
    -->
    </script>

  • Need Dynamic Table in JSP page

    Hi Friends,
    I need to build table dynamically in my JSP page.
    My requirement like:
    I have a Button in my JSP page when i click that it should go to another jsp where it will ask me the row and column counts, after i entered some values then i have a button to say OK it should go to the first page again there i want the table for the rows and columns dynamically.
    (like MS- Word when u create table it will ask the row count and column count after that its building a table)
    Please help me....

    Make use of JSTL's c:forEach.

  • Need ur help to create sl statement in jsp

    hello experts
    plz tell me how i can create a table in MS-ACESS with the help create table command (i want to create dynamic table within my jsp page)
    i tried this command
    String query3 = "CREATE TABLE Friends(message memo,author,text,postdate text,)";
    but it was not working plz help me

    is it giving you any error ?
    If yes , then please give the error message details

  • Passing Input Text Data to Dynamic TextBox in Another Scene

    Hi everyone there,
    I am creating a quiz for my school using flash.
    I am wondering if it is possible to pass the answers key in
    by students in the input text field to the dynamic textbox at the
    end of the entire quiz to show all the ans by the students and all
    the model ans of the quiz.
    May i know if this can be done?
    Or is it better to pass info from text box to text box in
    from one frame to another in the same scene?
    Also, how do i create a page that will list down the total
    number of questions the student has answered correctly and show her
    score?
    Thank you very much.
    FiOh
    *^^*

    An instructor at a summer camp told me to avoid scenes, so
    I've been afraid of them ever since.
    I'm not sure I quite understand the first post - you want the
    students to put in their own answer key?
    I made a quiz once. It was about genetics. This first frame
    had a "let's go" button that started the quiz. Each consecutive
    frame had a question and an oddball amount of input fields. The
    frame had each input set to a certain variable. At the end it added
    one to the score variable for each textfield that matched my magic
    answer. You could do all kinds of things this way. The syntax
    looked something like:
    if(input3A.text = whatever the answer is) {
    ++score; //adds to score variable
    and it could make a result3A_txt.text = "Bingo";
    "input3A" is arbitrary - for problem three, two, etc. the
    text field was called "input" and then a number, and then, if there
    was more than one text field for that problem, a letter. This is
    just the first field in problem three.
    The second line in the if statement talks to a field. You put
    a static text with the problem number, and next to it,
    result3A_txt. If the user answered the problem correctly, the field
    will become "Bingo" or something. You would do this for each
    problem so that every correct one would say "Bingo."
    To get a percent score:
    percent_txt.text = Math.round((score / max_score) *
    100);

  • Servlet with no dynamic code inside jsp pages

    Hello,
              I saw that a servlet is created even if there is no dynamic code inside jsp pages (scriplets & tags). Is it possible to avoid it on bea side ? (I am using portal 8).
              By the way, do you know if is it possible to define apache in order to avoid to send to bea the jsp which have no dynamic code inside ?
              thank you !

    JSP's always generate a servlet on all web containers. Apache/Tomcat is no
              different. If you have static content, make it an HTML page.
              Bill
              "hournon jc" <[email protected]> wrote in message
              news:22255787.1103297053148.JavaMail.root@jserv5...
              > Hello,
              >
              > I saw that a servlet is created even if there is no dynamic code inside
              jsp pages (scriplets & tags). Is it possible to avoid it on bea side ? (I am
              using portal 8).
              >
              > By the way, do you know if is it possible to define apache in order to
              avoid to send to bea the jsp which have no dynamic code inside ?
              >
              > thank you !
              

  • Creating graphs in my jsp

    Can anyone give me an idea of how I could dynamically create graphs in my jsp?
    Any help will greatly be appreciated! Thanks!

    Maybe an easy way is to use:
    http://coldjava.hypermart.net/servlets/bar.htm
    If that is too funky then use:
    http://www.acme.com
    http://www.acme.com/java/software/Acme.JPM.Encoders.GifEncoder.html
    to create your own.

Maybe you are looking for

  • Desktop skype client on windows 8.1 microphone not working suddenly

    Please help me! Until yesterday my desktop client worked perfectly on windows 8.1, use it all the time for work. However yesterday afternoon the microphone suddenly stopped working and no one can hear me. I haven't done any updates to anything etc. M

  • Batch determination in SD

    Hi, Batch determination setup for SD in spro: 1 - At SalesAreaTie to Batch Determination Schema LG=>BatchMgmt=>BatchDetermination&BatchCheck=>BatchSearchProcedureAllocation&CheckActivation=>AllocateSDSearchProcedure/ActivateCheck. 2 - At Sales Item C

  • I want to install windows 8.1 in my hp 430 which is running with windoes 7 ultimate 32 bit

    HP 430 Notebook PC I Dont have any option like that   when i want to install windows 8.1 

  • Illustrator CC trial version on mac

    I am new in illustrator, I am using the CC trial version, I have noticed that I cannot access the layers, Is that because the version is trial, so if I will subscribe the layers option will be available in CC version.

  • Object Library/PL-Sql Library Use?

    1. I would like to know the benefits of the new concepts like Object library and Object Group etc. All I gather is that they can be subclassed, the advantage of this being, I need to change only at one place, and it replicates in rest of the programs