41 users online (0 members and 41 guests)  

Thread: dynamic forms


  Results 1 to 5 of 5

Related

  1. dynamic web forms    Forum: HTML Forum
    Replies: 1
  2. Dynamic web forms    Forum: HTML Forum
    Replies: 4
  3. using forms to display dynamic data    Forum: Javascript Forum
    Replies: 1
  4. dynamic forms    Forum: HTML Forum
    Replies: 1
  1. #1
    saintchuck's Avatar
    New User

    Status
    Offline
    Join Date
    Jul 2005
    Posts
    2

    dynamic forms

    Is it possible to have dynamic content in a form based on previous form input?

    What I am trying to do is present a list of options in the form of a drop down list. The content of the drop down list will depend on the selection made to a radio button.

    I have looked through a number of HTML form tutorials but have not come across an answer. Is this possible with HTML or am I forced to use PHP?

    Any help greatly appreciated.

    More of a Webnovice than a Webmaster,

    Chuck

  2. #2
    HTML's Avatar
    Administrator

    Status
    Offline
    Join Date
    Aug 2000
    Posts
    3,445

    Follow HTML On Twitter Add HTML on Facebook Add HTML on Google+ Add HTML on Linkedin Visit HTML's Youtube Channel

    Re: dynamic forms

    This can be done with JS I believe, though somebody else will have to say how.

    Moving to the scripts forum.

    Dave

  3. #3
    ALL's Avatar
    Super Dooper Nerd

    Status
    Offline
    Join Date
    Feb 2005
    Location
    localhost
    Posts
    382

    Re: dynamic forms

    actually... yes it is possable to do with JS, but... you would either have to allow a file to be modified by anyone, or have a PHP/CGI/ASP/JAP exc... do it for you.

    to do what you are looking for it is quite simple script


    unless all you want is to have a radio button/check boxes display, with no submition to the server, you could do that eassily with JS

  4. #4
    saintchuck's Avatar
    New User

    Status
    Offline
    Join Date
    Jul 2005
    Posts
    2

    Re: dynamic forms

    I am restricted by hosting plan in regards to what I can/can't do. The lack of database access may not allow me to do what I need unfortunately.

    I will give the exact problem in hopes that someone can give/point me to a skeleton of code that I can modify to suit my needs.

    I am attempting to create a puppy wishlist. The user can choose (Collie/Min Pin) based on a radio button. Depending on which breed they select the drop down list will display choices of coat color for that particular breed. Upon submitting, the form is emailed to me using a host company supplied php script.

    I have come across code that will hide another form element based on a radio button selection and might be able to modify it so that it hides/reveals the 2 lists alternately but am trying for a more elegant solution.

  5. #5
    ALL's Avatar
    Super Dooper Nerd

    Status
    Offline
    Join Date
    Feb 2005
    Location
    localhost
    Posts
    382

    Re: dynamic forms

    play around with code like this:
    HTML Code:
    <html>
    
    <head>
    <script>
    function somthing(title, id){
    document.getElementById('maindata').innerHTML=document.getElementById('maindata').innerHTML+'<div style="border: 1px solid #0000FF; background-color:#FFFFE0; width:221px; height:120px;"><form><p align="center">'+title+'</p><input type="radio" value="V1" name="R1" onclick="somthing(\'Title \'+this.number+2, this.number+1);">something<br>	<input type="radio" value="V2" name="R1">another thing<br>	<input type="radio" value="V3" name="R1">here too<br>	<input type="radio" value="V4" name="R1">something else<br>	<input type="radio" value="V5" name="R1">one more</form></div>';
    //document.getElementById('div1').disabled=false;
    }
    function done(){
    document.getElementById('waiting').innerHTML='<input type="submit" value="Submit" name="B1">';
    document.getElementById('waiting').disabled=false;
    }
    </script>
    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Page Title</title>
    </head>
    
    <body>
    <form action="scriptname.php">
    <div style="border: 1px solid #0000FF; background-color:#FFFFE0; width:221px; height:120px;">
    <p align="center">Title 1</p>
    <form>
    		<input type="radio" value="V1" name="R1" number="0" onclick="somthing('Title '+this.number+2, this.number+1);">something<br>
    		<input type="radio" value="V2" name="R1" number="0">another thing<br>
    		<input type="radio" value="V3" name="R1" number="0">here too<br>
    		<input type="radio" value="V4" name="R1" number="0">something else<br>
    		<input type="radio" value="V5" name="R1"  number="0" onclick="done();">done!</form>
    </div>
    <div id="maindata"></div>
    <div id="waiting" style="border: 1px solid grey; background-color:lightgrey; width:221px; height:120px;" Disabled>&nbsp;<p>Waiting for first Pick...</div>
    </form>
    </body>
    
    </html>



Tags for this Thread