SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: text boxes

  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2003
    Location
    Pakistan
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    text boxes

    if we have 10 text boxes on our web page and all have same name then how can we post the data into a database....i mean to sat that how would we difrenciate that what data is in which text box. i mean that if text boxes' name is "nametxt" so how can we use data from all the text boxes... this happens when i use java script to put multiple text boxes on the form usin a button click so now all have same name and i want to know that how can i get the data from each text boxh becaue all have same name
    regards

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not sure why you posted this here; the original thread, which Danne answered, was here. Anyway...if you were using PHP, you could just name the fields "nametxt[]" and you'd get an array; otherwise:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" 
        "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    <head>
    <title>untitled</title>
    
    <script type="text/javascript" language="javascript">
    
    var fieldnum = 1;
    
    function addField(container) {
        var f = document.createElement("INPUT");
        f.setAttribute("type", "text" );
        f.setAttribute("name", "nametxt" + fieldnum++);
        f.setAttribute("value", f.getAttribute("name")); //demo only, remove
        container.appendChild(f);
        container.appendChild(document.createElement("BR"));
    }
    
    </script>
    </head>
    <body>
    <form onsubmit="return false;">
    <input type="button" value="Add" onclick="addField(document.getElementById('cont'))">
    </form>
    <div id="cont"></div>
    </form>
    </body>
    </html>
    hth
    ::: certified wild guess :::


Bookmarks

Posting Permissions

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