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
    Regular Coder
    Join Date
    Dec 2009
    Posts
    243
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Form Creation Questions.....

    I have a few form creation questions for you...

    What I would like to do is the following..

    Add a text box so that I can add a new category,
    Add a submit button.. Submits the new category to the database.


    Somewhere underneath I would like the option of adding a sub category to that page if need be.. Whats the best way?

    When I submit the new category above it asks me if I want to add a sub category to it then?

    Or can I somehow create something below which links it to the new category??

  • #2
    New Coder
    Join Date
    Aug 2009
    Posts
    40
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Exclamation

    The best thing to do for all this is PHP. But if your looking to
    Add a text box so that I can add a new category,
    try the HTML DOM from W3Schools Here or try out the code bellow:
    Code:
    <HTML>
    <HEAD>
    <TITLE>Dynamically add Textbox, Radio, Button in html Form using JavaScript</TITLE>
    <SCRIPT language="javascript">
    function add(type) {
    
    	//Create an input type dynamically.
    	var element = document.createElement("input");
    
    	//Assign different attributes to the element.
    	element.setAttribute("type", type);
    	element.setAttribute("value", type);
    	element.setAttribute("name", type);
    
    	var foo = document.getElementById("fooBar");
    
    	//Append the element in page (in span).
    	foo.appendChild(element);
    
    }
    </SCRIPT>
    </HEAD>
    <BODY>
    <FORM>
    <H2>Dynamically add element in form.</H2>
    Select the element and hit Add to add it in form.
    <BR/>
    <SELECT name="element">
    	<OPTION value="button">Button</OPTION>
    	<OPTION value="text">Textbox</OPTION>
    	<OPTION value="radio">Radio</OPTION>
    </SELECT>
    
    <INPUT type="button" value="Add" onclick="add(document.forms[0].element.value)"/>
    
    <span id="fooBar">&nbsp;</span>
    
    </FORM>
    </BODY>
    </HTML>
    hope this helped a bit


  •  

    Posting Permissions

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