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
  1. #1
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Dynamic input form field elements, works IE not FF

    I've been looking for a javascript like this example: http://javascript.internet.com/forms/dynamic-input.html

    Here you can fill in (in this example) a number of URLS, then this script adds a number of fields on the HTML page.

    The example works from internet.com in internet-explorer but not in firefox.

    Does anybody has experience to create this javascript cross-browser compatible? Or does anybody has maby another examples by getting these functions.

    Thanks in advance!

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,535
    Thanks
    3
    Thanked 513 Times in 500 Posts
    Code:
    <!-- TWO STEPS TO INSTALL DYNAMIC INPUT:
    
      1.  Copy the coding into the HEAD of your HTML document
      2.  Add the last code into the BODY of your HTML document  -->
    
    <!-- STEP ONE: Paste this code into the HEAD of your HTML document  -->
    
    <HEAD>
    
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Original:  Peter Hermus -->
    <!-- Web Site:  http://come.to/speedpete -->
    
    <!-- This script and many more are available free online at -->
    <!-- The JavaScript Source!! http://javascript.internet.com -->
    
    <!-- Begin
    function createForm(number) {
    data = "";
    inter = "'";
    if (number < 16 && number > -1) {
    for (i=1; i <= number; i++) {
    if (i < 10) spaces="      ";
    else spaces="    ";
    data = data + "URL " + i + " :" + spaces
    + "<input type='text' size=10 name=" + inter
    + "url" + i + inter + "'><br>";
    }
    if (document.layers) {
    document.layers.cust.document.write(data);
    document.layers.cust.document.close();
    }
    else {
    document.getElementById('cust').innerHTML = data;
    
       }
    }
    else {
    window.alert("Please select up to 15 entries.");
       }
    }
    //  End -->
    </script>
    </HEAD>
    
    <!-- STEP TWO: Copy this code into the BODY of your HTML document  -->
    
    <BODY>
    
    <center>
    <form name=counter>
    Number of URLs to enter:
    <input type=text name=number size=5>
    <input type=button value="Update" onClick="createForm(counter.number.value);">
    </form>
    
    <br>
    
    <form name="webform">
    <table border=0>
    <tr valign=top>
    <td>Name:</td>
    <td><input type=text size=20 name=name  id=name onChange="msg(this.form)"></td>
    </tr>
    
    <tr><td colspan=2>
    
    <!-- Placeholder for dynamic form contents -->
    <span id=cust style="position:relative;"></span>
    
    </td>
    </tr>
    
    <tr valign=top>
    <td>Comments:</td>
    <td><textarea name=comments cols=45 rows=5 wrap=virtual OnChange="msg(this.form)">
    </textarea></td>
    </tr>
    <tr>
    <td></td>
    <td><input type=submit value="Send"></td>
    </tr>
    </table>
    </form>
    </center>
    
    <p><center>
    <font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
    by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
    </center><p>
    
    <!-- Script Size:  1.95 KB -->
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/


  •  

    Posting Permissions

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