To dynamically  generate text box using javascript

hi...
i want to have a button such that if he clicks that button 2 textboxes be generated side by side.
i want the textboxes to be added just above the button so that the button is always below the newly created textboxes.
its not only once i want this ..i want that whenever he clicks the button 2 textboxes gets added everytime...
how can i achieve this?
thanks

Ok, so this is a complete thread hijack - probably would have been worth a new thread.
The initial solution involved javascript completely.
The problem breaks down to
1 - identify when we should move focus
2 - identify which field focus should move to.
Here is one version. This approach gives each textfield an individual name/number so you can find its "matching" pair.
<html>
<head>
  <script>
  var numLinesAdded = 0;
  function focusNext(tBox){
    var name = tBox.name;
    var index = name.substring(name.indexOf('_')+1);
    var brother = eval("document.all.txt2_" + index);   
    var l = tBox.value.length;   
    if (l >= tBox.maxLength){
      brother.focus();
     function generateRow() {
     var d=document.getElementById("div");
     d.innerHTML+="<input type='text' maxlength='5' name='txt1_" + numLinesAdded + "' onkeypress='focusNext(this)'>";
     d.innerHTML+="<input type='text' name='txt2_" + numLinesAdded + "'><br>" ;
     numLinesAdded++;
</script> 
</head>
<body>
<form>
<div id="div"></div>
<input type="button" value="Add" onclick="generateRow()"/>
<input type="submit">
</form>
</body>
</html>

Similar Messages

  • AnyChart: Dynamically add/remove series using javascript

    Hi all,
    The examples on the following page they dynamically show/hide series using javascript without any server side action.
    http://www.anychart.com/products/anychart/docs/users-guide/livesamples/js-series/index.html
    It seems they can do this because they add the chart to the page using javascript and so other js scripts can access a reference to the chart object. Looking at the code generated when you add a flash chart using Apex, it appears they are embedded flash. Does this stop us from using javascript to manipulate the chart object?
    Has anyone managed to do something like the example in the page above using the built-in charting of Apex?

    Between me and another poster we've sort of worked out a solution here - Re: Apex 4.0.2 Manipulate Flash Charts using Javascript?

  • Get the value of output text box in javascript

    Hi all,
    I am trying to retreving the value of output text box using getElementById('form1:outputText3') but was not able to get it.
    Googled it but didnt find any way to get it on the page itself without going to backing bean
    jdeveloper version 10g
    Thanks in advance

    Hi,
    I think this is because out put text is not a component but text written to the page. So I thin you would have to parse the generated HTML for it or use a inputText field and set it to read only
    Frank

  • How can I automatically close a dialog box using Javascript after I click the OK button to submit it?

    How can I automatically close a dialog box using Javascript after I click the OK button to submit it? I don't want to have to X out of the dialog box after I am done.
    Thanks
    Linda

    JS can not interact with open dialogs in any way, unless it's a dialog
    created in JS using the Dialog object.
    On Thu, Jul 24, 2014 at 11:13 PM, lindaeliseruble <[email protected]>

  • How can I change the background color in text box using RGB format

    Can some one tell me if Mac Pages (version 5.0) allows users to customize the background color of a text box using RGB color format?  It appears that the text color can be changed using RGB but background color is limited to a few standard colors.   Thanks

    They are just sample swatches, use the Color Picker to choose anything you want.
    Peter

  • ID CC 9.2.1: Interactive PDF, text boxes use wrong font

    When filling out text boxes of an interactive PDF (created with InDesign CC 9.2.1) in Adobe Reader X, the font used is always Times Roman or such. Whatever I've tried so far, I fail to make the interactive text boxes use a specific font. Should be the same font that's used for the rest of the text on the page. During exporting the PDF, I've instructed InDesign to embed all font glyphs.
    Is there a way to get around this problem?
    Andreas

    You have to work on it after exporting to PDF in Acrobat Pro and change the font there.
    BUT: Don't choose exotiv fonts, use the normal standard form fonts, otherwise the file size will increase, because every font in the form must be embedded. Another problem is that older versions of Adobe Reader or Acrobat or some other possible PDF readers only support the standard form fonts, like Helvetica, Times, Courier in Bold, Regular, Italic, and Bold Italic. So it is better to submit to this limitations.

  • Generating text file using PL/SQL

    can any body send sample program how to generate text file using PL/SQL program.I want to store table data into that text file.

    Hi,
    try this.
    Thanks
    CREATE OR REPLACE procedure write_index (TABLE_NAME_ACCEPT VARCHAR2) IS
    id UTL_FILE.FILE_TYPE;
    name VARCHAR2(20) := 'e:\db_coca\input';      
    err VARCHAR2(100);      
    ColNameLength Integer;
    NumberoFColumns Integer;
    num NUMBER;           
    i integer;
    loc_query VARCHAR2(2000);
    cursor_name INTEGER;
    ret INTEGER;
    l_const_name VARCHAR2(30);
    CURSOR c_columns(i_Constraint_name VARCHAR2) IS
         SELECT *
         FROM     all_cons_columns
         WHERE     CONSTRAINT_NAME = i_Constraint_name
         order by table_name;
    BEGIN
    DBMS_OUTPUT.PUT_LINE('BEFORe OPEN');
    --id := UTL_FILE.FOPEN('e:\db_coca\input',name,'w');          
         --IF UTL_FILE.IS_OPEN(id) THEN
         --     DBMS_OUTPUT.PUT_LINE('Opened');
         --ELSE
         --     DBMS_OUTPUT.PUT_LINE('Still Closed');           
         --END IF;          
    DBMS_OUTPUT.PUT_LINE('AFTER OPEN');
    --The table generation script
         loc_query := 'Select CONSTRAINT_NAME from user_constraints ';
         loc_query := loc_query || ' where owner = ' || '''CPS''';
         loc_query := loc_query || ' AND CONSTRAINT_TYPE = ' || '''P''';
         dbms_output.put_line('TABLE_NAME_ACCEPT = ' || TABLE_NAME_ACCEPT);
         IF NOT (TABLE_NAME_ACCEPT IS NULL ) THEN
              loc_query := loc_query || ' AND TABLE_NAME like ''';
              loc_query := loc_query || TABLE_NAME_ACCEPT ;
              loc_query := loc_query || '''';
         END IF;
         cursor_name := DBMS_SQL.OPEN_CURSOR;
    dbms_output.put_line('Query = ' || loc_query);
         DBMS_SQL.PARSE(cursor_name, loc_query, DBMS_SQL.v7);
    dbms_output.put_line('After parse');
         dbms_sql.DEFINE_COLUMN(cursor_name, 1,l_const_name, 30);
         ret := DBMS_SQL.EXECUTE(cursor_name);
    --     IF ret > 0 THEN
         LOOP
         dbms_output.put_line('return = ' || ret);
              IF DBMS_SQL.FETCH_ROWS(cursor_name) > 0 THEN
                   dbms_sql.COLUMN_VALUE(cursor_name, 1,l_const_name);
              --     dbms_sql.BIND_VARIABLE(cursor_name,
    l_const_name,CONSTRAINT_NAME);
              --     FOR C10 in Table_Loop Loop          --The cursor
    for the table name
                   Select COunt(*) INTO NumberoFColumns from
                   all_cons_columns
                   Where CONSTRAINT_NAME = l_const_name;
         --          FOR C11 IN c_columns(l_const_name) LOOP
         --          End loop;
         --          UTL_FILE.PUT(id, ');');
              ELSE EXIT;
              END if;     --THe 1 st cursor if is closed
         End Loop;     --The table loop ends here
              DBMS_SQL.CLOSE_CURSOR(cursor_name);
    --     END IF;     
    --     UTL_FILE.PUT_LINE(id,name);
    --     UTL_FILE.PUT(id,'It worked and wrote to this file');
         UTL_FILE.FCLOSE(id);
         DBMS_OUTPUT.PUT_LINE('Successful write to file');          
    EXCEPTION     
    WHEN OTHERS THEN               
         err := SQLERRM;          
         num := SQLCODE;
         DBMS_OUTPUT.PUT_LINE(err);          
         DBMS_OUTPUT.PUT_LINE(num);
         DBMS_OUTPUT.PUT_LINE('Error in writing to file');     
    END write_index;

  • Help needed in getting values from the dynamically created text boxes

    Hello,
    I am developing one jsp page using struts. In the page i m
    dynamically adding some rows with two text boxes in each row. and after entering data into
    those textboxes , user clicks on save button and page is submitted.
    I want to capture all this data of dynamically added
    rows so that i can enter those rows into DB.
    how can i acheive this using struts?.
    Have anyone had tried doing it?. Please help.
    Thanx in advance
    Deepali Naik

    Hi,
    1. If you give these textBoxes the same name, then in your action you can call request.getParameterValues(paramName) - it returns String[ ] of values.
    2. You can give form textBox names like "name"+index or something like this in <logic:iterate> tag
    Good luck!

  • Dynamic popup text box...

    I have a text box with a ton of text in it (multiple
    paragraphs). Functionally, what I'd like to do is have it so that I
    can have people click on (or roll over) certain words, and then a
    definition pops up in a blue box (kinda like a tooltip)...
    I could make one "box" movieclip with a dynamic text field in
    it, and then just use it as a transparent button over each word
    that needs to be defined within the paragraph (loading the
    definition text inside the "box" dynamically), but I wouldn't know
    how to adjust the size of the box so that it fits each definition's
    text. (like, some definitions may be a couple words, and some may
    be a sentence or two, so if the box is always just one size, that
    won't work)...
    That being said, the only thing I can think of is having a
    separate "box" movieclip (each sized to its separate dimentions) in
    the library. But with all of those definitions, that will increase
    the file size huge...
    There's gotta be a simple solution to this that I'm missing -
    any ideas?! Thanks!...

    quote:
    Originally posted by:
    kglad
    to size your textfield use the autoSize property of
    textfields.
    I thought of that too. That solves the problem of the text
    field itself being the correct size, but I then need the box_mc
    that the text field is IN to be sized correctly....
    ...the reason I need the text field in a box (as opposed to
    just stand-alone) is simply for aesthetics. I need a
    semi-transparent blue background behind the text.
    Is there a way (maybe) to auto-size the text field, then grab
    the size that it was autosized to into variables, then apply those
    variables to size the box_mc??? I'm just grasping at straws here -
    I don't even know if that's possible...
    ...if it IS possible, could someone help get me started with
    a sample code? Thanks!

  • Dynamically generating text item in developer

    Hi,
    I am developing applicationn in developer 6i and I am facing problem regarding
    displaying records in form. My query is
    select ename, edept from sale where city = 'NYK'
    suppose this query fetch 10 records and I dispalyed them in developer but problem is that I donot
    want to display scroll bar in form and only 10 text items to display 10 record.
    some times my query fetch 15 record and I have opted to display 10 record and unchecked the
    scroll bar in FORMs designing it displays 10 records and 5 records where shown when i use
    key board to go down and then I can see them.
    kindly tell me whether I can use some commands to generate text items
    dynamically depending upon my records.
    If I have ten record then only 10 text items will be displayed and if 15
    then only 15 text items.
    Thanks

    Hi,
    You cannot create items at run time.
    You could create the items at design time in a control block and programatically show or hide them based on a query to retrieve the details you need.
    I would ask why you want to do this. Enable the scrollbar, let the users scroll up and down and you get all the functionality for free. No need to create a control block, populate it, control the number of displayed items, considerations on canvas size when number displayed would overflow canvas.
    Oracle spends billions of dollars developing software so you don't have to go through the pain.
    If you cannot simply do something in forms, then question the requirement, not try to re-engineer Forms
    Neil

  • Accesing dynamically generated UI elemnts using Automation tool

    Hi,
    I want to test my iOS app. It contains dynamically generated UI elemnts.
    I can't print them with logElementTree() and I don't know how to access the  dynamically generated elements.
    If there is any way I can access dynamically generated elements using a script?
    Any help will be highly apreciated
    Thank You and best regards
    Aruna

    I am beginning to think that there is no solution to my problem. Let me better define the problem:
    1. Automation tool does not see extended check box.
    2. The container of extended check box is standard tree (nothing to instrument).
    3. Extended check box is third party component which was derived from standard button, and not standard check box (theoretically nothing to instrument again).
    4. Extended check box was used in item renderer class of the tree.
    Maybe elements used in item renderers cannot be exposed to automation tools (I have tried FlexMonkey and RiaTest, but they both failed)?

  • Rich text box used in Infopath Form not displaying option to get images from Computer

    Hello,
    We have used "Rich text box" in Infopath Form which is not displaying option to get images from Computer.
    Options available are : From Address, From SharePoint
    But if we Rich text box in list, then it works fine with "From Computer" option.
    can you please help me out to get this option.
    Thanks in advance.
    REgards,
    Jayashri

    Hi,
    From your description, there is no “From Computer” option to get images with rich text box in InfoPath form.
    Per my knowledge, by design there are “From Address” and “From SharePoint” options without “From Computer” option in rich text box in InfoPath form. As a workaround, you can develop a custom InfoPath Rich Text box to do it.
    About developing a custom InfoPath control, I suggest you create a new thread on the forum “Visual Studio Tools for Office”, more experts will assist you with InfoPath development.
    Visual Studio Tools for Office:
    https://social.msdn.microsoft.com/Forums/office/en-US/home?forum=vsto&filter=alltypes&sort=lastpostdesc
    Thanks,
    Dean Wang

  • Read-Only Text Field Using JavaScript Code

    I'd like to make a text field read-only by using JavaScript and also having IF & ELSE statements.
    I want it to be like this:
    if the answer from the dropdown menu is YES, then the text field is read only but if the answer is NO then the text field is fillable.
    Thanks in advance

    Use this code as the custom validation script of the drop-down in question:
    this.getField("Text1").readonly = (event.value=="Yes");

  • Convert PDF to Word - Tables are in Text Boxes using Acrobat 11. How can this be avoided?

    Hello All,
    I am using Acrobat 11 to convert PDF's to MS Word .doc or .docx. The tables are converted correctly but they are inside Text Boxes. My documents have hundreds of tables and I cant manually remove the text boxes.
    Is there a way to remove the Text Box that contains each table?
    Regards Paul

    Hello Anubha,
    My apologies.  Hopefully you can see the table is inside a text box. The Acrobat 7 doesn't behave like this, nor do some of the other PDF conversion products.
    In my output there is 700 pages with average of 3 tables per page. A manual workaround to get the tables out of the text boxes wouldn't be practicable.
    Can you confirm that this is not the expected behaviour. I thought I recently saw a video showing this behaviour as standard for Acrobat 11.
    Regards Paul

  • Dynamically validating datatable elements using javascript

    Hai, iam using jsf, and having Xml mapping to the form elements to display the data . Iam using <h:datatable> inside which iam haveing repeated elements, i need to do a javascript validation before displaying the form element present inside the <h:datatable> columns.Iam also using <j4j:idproxy> , the java script is working for 1 iteration but it is the dataof the form element is not getting overridden in the 2nd iteration, It is somethinglike this below.
    <TR id="buiCoverRowId" style="display:none;">
    <TD height="9" width="200"></f:verbatim> <h:outputText
    styleClass="outputText" id="text7"
    value="Buildings Cover"></h:outputText><f:verbatim></TD>
    <TD height="9" width="516"></f:verbatim> <h:outputText
    styleClass="outputText" id="buildCoverId"
    value="#{pathPart.xpathMap['./BuildingsCover/CoverDetail/SumInsured/Amount']}">
    </h:outputText> <f:verbatim></TD>
    </TR>
    <TR>
    <TD></f:verbatim><f:verbatim>
    <h:inputHidden id="hidBuiCoverId"
    value="#{pathPart.xpathMap['./BuildingsCover/CoverDetail/SumInsured/Amount']}">
    <j4j:idProxy id="hidBuiCoverId_" />
    </h:inputHidden>
    </f:verbatim><f:verbatim></TD>
    <TD></f:verbatim><f:verbatim>
    <h:inputHidden id="hidExBuiCoverId"
    value="#{pathPart.xpathMap['./BuildingsCover/ExcludedInd/Value']}">
    <j4j:idProxy id="hidExBuiCoverId_" />
    </h:inputHidden>
    </f:verbatim><f:verbatim></TD>
    </TR>
    <SCRIPT>
    alert("HAI");
    var buidcover = document.getElementById('hidExBuiCoverId_').title;
    var buidcoverR =document.getElementById(buidcover).value;
    alert("the value of buildcover----->"+buidcoverR);
    var buId =document.getElementById('hidBuiCoverId_').title;
    var entitybuId1 = document.getElementById(buId).value;
    entitybuIdT1 = trim(entitybuId1);
    alert("entitybuIdT1"+entitybuIdT1);
    var buExId = document.getElementById('hidExBuiCoverId_').title;
    var entitybuExId1 = document.getElementById(buExId).value;
    entitybuExIdT1 = trim(entitybuExId1);
    entitybuExIdU1 = entitybuExIdT1.toUpperCase();
    alert("entitybuExIdU1"+entitybuExIdU1);
    if(!(entitybuIdT1 == null || entitybuIdT1 == '') && ((entitybuIdT1 == "0")) && (entitybuExIdU1 == 'FALSE'))
    document.getElementById("buiCoverRowId").style.display="block";
    </SCRIPT>
    The form element is mapped to the xml. the above code is written within a datatable, iam using javascrpt within this to display the datat or not, it is working for first iteration but its not working for second iteration. Plz help me with this . Is there any way that i can use javascript so that it vvalidates the form elements even for the 2 iteration of the datattable. I am having thesame values (of the 1iteration) even during the 2 iteration. Plz help me with this asap.

    Got the solution.
    $("div.ms-acal-rootdiv div div div a").html().replace('Replace this text only.','Replaced Text');

Maybe you are looking for