...

View Full Version : Form Creation Questions.....



Byronwells
01-11-2010, 05:59 PM
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??

FrickenTrevor
01-12-2010, 05:25 AM
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 (http://www.w3schools.com/HTMLDOM/dom_examples.asp) or try out the code bellow:


<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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum