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 4 of 4

Thread: Dinamic Form

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

    Exclamation Dinamic Form

    Hi,

    I need to create a form like hotmail's registration one..you know?

    Its a hotels reservation form. I need the form to autochange when the hotel is selected.

    Anyone can give any clue, link tutorial or example??
    Thanks In advance

    Andres

  • #2
    New Coder
    Join Date
    Nov 2002
    Location
    London, UK
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

    Not really sure what you need but i would recommend reading up on the DOM for dynamically creating elements.

    heres a good tutorial to start.

    http://www.brainjar.com/dhtml/intro

    Adam

  • #3
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    If the form is fairly long you'd be better off having the user enter some basic information (including the hotel) then continuing to another page based on which hotel they chose.

    To answer your question, it's really easy to do this in IE, but Netscape and other browsers don't like it. This example works on NS4+ and IE, but requires absolute positioning.

    Code:
    <html>
    <head>
    <script language="javascript">
    function showhide(checkval){
      var colData = "Here is my hidden text.";
      if (document.layers){
        document.layers['mylayer'].document.open();
        document.layers['mylayer'].document.write("<form name='mylayer'>");
        document.layers['mylayer'].document.write(colData);
        document.layers['mylayer'].document.write("</form>");
        document.layers['mylayer'].document.close();
        document.layers['mylayer'].visibility=(checkval=="hide") ? 'hide' : "show";
      }
      else{
        document.all['mylayer'].style.visibility=(checkval=="hide") ? 'hidden' :"visible";
        document.all.mylayer.innerHTML = colData;
      }
    }
    </script>
    </head>
    <body>
    <form>
    <select name="myfield" onchange="showhide(this[this.selectedIndex].text);">
    <option>hide</option>
    <option>show</option>
    </select>
    </form>
    <div id='mylayer' style="position:absolute;left:10px;top:500px">&nbsp;</div>
    </body>
    </html>

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You are welcome to draw inspiration from a dynamic form I created for a car rental business. Hotel reservations should not be that much different...
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"


  •  

    Posting Permissions

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