Loading ...
Sorry, an error occurred while loading the content.

Re: [JavaScript] Add Text Field

Expand Messages
  • Tim Sabin
    1) Insert a span into your HTML so you can set the contents: 2) Set the contents of the with
    Message 1 of 3 , Dec 12, 2008
    • 0 Attachment
      1) Insert a span into your HTML so you can set the contents:
      <input type="text" ...>
      <span id="anotherTextBox">
      </span>

      2) Set the contents of the <span> with JavaScript:
      function addText () {
      document.getElementById ("anotherTextBox").innerHTML = "<input
      type='text' ...>";
      }

      --Tim Sabin


      > Dear all,
      >
      > How to add text field by javascript ? I want to enter some data,
      and for first time, only there is one text field, when I enter the
      first text field, there is a text field below the first automatically
      (by javascript). Please assist me... Thx.
      >
      >
      > ---------------------------------
      > Importing contacts has never been easier..
      > Bring your friends over to Yahoo! Mail today!
      >
      > [Non-text portions of this message have been removed]
      >
      >
      > ------------------------------------
      >
      > Visit http://aiaiai.com for more groups to joinYahoo! Groups Links
      >
      >
      >
      >
    • dhaval vekariya
      Hi Repalce with this code when u click on the like one text box created with div and when u click on any textbox it will remove..
      Message 2 of 3 , Dec 15, 2008
      • 0 Attachment
        Hi Repalce with this code
        when u click on the like one text box created with div and when u click on any textbox it will remove..

        <html>
        <head>

        <script language="JavaScript">
        function addElement() {
        var ni = document.getElementById('myDiv');
        var numi = document.getElementById('theValue');
        var num = (document.getElementById('theValue').value -1)+ 2;
        numi.value = num;
        var newdiv = document.createElement('div');
        var divIdName = 'my'+num+'Div';
        newdiv.setAttribute('id',divIdName);
        newdiv.innerHTML = "<input type='text' value= '"+divIdName+"' onclick=\"removeElement('"+divIdName+"' )\" />";
        ni.appendChild(newdiv);
        }
        function removeElement(divNum) {
        var d = document.getElementById('myDiv');
        //alert(d.value + " ok " + divNum);
        var olddiv = document.getElementById(divNum);
        //alert(olddiv + " -- " + olddiv.value);
        d.removeChild(olddiv);
        }
        </script>
        </head>
        <body>
        <input type="hidden" value="0" id="theValue" />
        <p><a href="javascript:;" onclick="addElement();">Add Some Elements</a></p>
        <div id="myDiv"> </div>
        </body>
        </html>



        Have a Nice Day.

        With Regards,
        DHAVAL J. VEKARIA






        ________________________________
        From: Watson L <phpmks@...>
        To: JavaScript Official <javascript_official@yahoogroups.com>
        Sent: Friday, 12 December, 2008 12:14:26 PM
        Subject: [JavaScript] Add Text Field


        Dear all,

        How to add text field by javascript ? I want to enter some data, and for first time, only there is one text field, when I enter the first text field, there is a text field below the first automatically (by javascript). Please assist me... Thx.

        ------------ --------- --------- ---
        Importing contacts has never been easier..
        Bring your friends over to Yahoo! Mail today!

        [Non-text portions of this message have been removed]




        Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/

        [Non-text portions of this message have been removed]
      Your message has been successfully submitted and would be delivered to recipients shortly.