Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: javascript code

  1. #1
    New to the CF scene
    Join Date
    Mar 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    javascript code

    12 hours, 2 minutes ago|LINK

    I have 1 text box name: createcontrolbox:...........................................

    quantity:........................................................

    one button .........create.....................

    i have to enter suppose: text ........

    5 then

    click button

    it should show me 5 text box.......should be created. need help

    <!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>
    <title></title>
    <script language="javascript" type="text/javascript">
    function create() {

    var res1 = document.getElementById("Text1");
    var res = document.createElement("Text1");
    res.tagName = "text";
    var res2 = document.getElementById("Text2");
    res.value = "Text2";
    alert(res);
    }


    </script>
    </head>
    <body>
    <table>
    <tr>
    <td>
    <label for="ctrlname"> Createcontrol*</label></td>
    <td><input type="text" id ="Text1" name="Createcontrol" maxlength="50" size="30"/></td>
    </tr>
    <tr>
    <td><label for="quantity"> quantity*</label></td>
    <td><input type="text" id ="Text2" name="quantity" maxlength="50" size="30"/></td>
    </tr>
    <tr>
    <td><input type="button" id ="btncr" value= "create" onclick="create()"/></td>

    </tr>





    </table>

    </body>
    </html>

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,348
    Thanks
    23
    Thanked 618 Times in 617 Posts
    You don't tell us where to put the text box or what to put in it.
    I took the language="javascript" out of your script tag, it's not needed.
    I added a second set of td's to the last row of the table as per table rules(?)
    Code:
    <!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>
    <title></title>
    <script type="text/javascript">
    function create() {
    	var box = document.createElement("input");
    	document.body.appendChild(box);
    }
    </script>
    </head>
    
    <body>
    <table>
    <tr>
    <td><label for="ctrlname"> Createcontrol*</label></td>
    <td><input type="text" id ="Text1" name="Createcontrol" maxlength="50" size="30"/></td>
    </tr>
    
    <tr>
    <td><label for="quantity"> quantity*</label></td>
    <td><input type="text" id ="Text2" name="quantity" maxlength="50" size="30"/></td>
    </tr>
    
    <tr>
    <td><input type="button" id ="btncr" value= "create" onclick="create()"/></td>
    <td></td>
    </tr>
    </table>
    </body>
    </html>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •