|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How do I use javascript to dynamically show form fields when a selection has been made from a drop-down menu? The fields can be one or many select boxes, radio boxes, text boxes, etc.
Is this possible? Thanks |
|
#2
|
|||
|
|||
|
If you do not want to reload the page you can use select menus. If someone makes a choice in one list the other lists adjust accordingly. This is possible because you can dynamically add, remove or edit options in a select list by using JavaScript. There are a lot of tutorials available on-line that can help you with this. Probably Devshed has a tutorial on this topic.
If you want to visually adjust other form elements you have to reload your page, with some additional parameters or use a frameset to have the intial choice in one frame and the rest of the form in another one. . ------------------ Ramon Litjens Boradoli Web Design (www.boradoli.nl) |
|
#3
|
|||
|
|||
|
Lets say you have a form named myForm and in that form you have a drop down menu as follows
<select name="mySelect"> <option value="value1">value1</option> <option value="value2">value2 plus some text</option> <option value="value3">value3</option> </select> and you have a field you want the selcted copied to: <input type="text" name="myField"> you the make a small script (remember to place it between the <head></head>-tags for good styles sake) <script language="javascript" type="text/javascript"> function myFunction(theForm) { theForm.myField.value = theForm.mySelect.value; } </script> now all you need to do is to make the dropdown call the function. You do that by adding a bit of code to the <select>-tag: <select name="mySelect" onChange="myFunction(this.form)"> You can also call it using onKeyUp, onkeypress etc. // Martin |
|
#4
|
|||
|
|||
|
I had the same problem.
What I resorted to was executing a new cgi script when the change event occured. The cgi script then determined the contents of the new page and re-sent them. This method saves having to have multiple html pages that are all similar. |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > dynamic fields |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|