Markie
Posts: 251
|
| Posted: 10/24/2008, 2:00 AM |
|
I'm building a simple form. I want to hide the fields of the form and show them only after the previous field has been filled / changed. Is there a simple procedure for this ?
Example:
the form starts with one visible field
the field is filled by the visitor
the next field automatically appears and also gets the focus
this next field is filled and the third field gets the focus
I only have three fields at the moment
M@rkie
_________________
The Netherlands, GMT+1
Tools: CCS 5.1, Windows 7, Navicat, Ultraedit
Local server: XAMPP with Apache, php and MySQL
Webserver: Windows 2008 IIS 7, php and MySQL |
 |
 |
melvyn
Posts: 333
|
| Posted: 10/24/2008, 7:53 PM |
|
You must use Javascript. Plain javascript, I recomend JQuery, try this post: http://forums.yessoftware.com/posts.php?post_id=101266&s_keyword=jquery
With plain javascript do this:
The first input:
<input onclick="showField2()" " maxlength=""25" size="25" name="field1"></strong><font size="2">
Replace the onclick event with onchange, onfinish or whatever event you like.
The second input:
<input style="display: none" maxlength="25" size="25" name="{field2_Name}">
The Javascript:
<script language="JavaScript">
// Show and Hide Shipping controls
function showField2() {
document.forms[0].field2.style.display = '';
}
function hideField2(){
document.forms[0].field2.style.display = 'none'; //use if needed.
}
if only have a form then document.forms[0].... will work. if more than 1, set the index [0], [1], as apropiate. You can say also document.forms["my_form_name"]...
Enjoy.
_________________
Melvyn Perez
Puro Codigo
http://purocodigo.com |
 |
 |
|