HTML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignHTML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 28th, 2000, 03:24 PM
brad czika brad czika is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2000
Location: Ashburn, VA, US
Posts: 1 brad czika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old February 29th, 2000, 05:14 AM
Ramon Ramon is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 1999
Location: Helden,Limburg,The Netherlands
Posts: 33 Ramon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
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)

Reply With Quote
  #3  
Old March 30th, 2000, 09:50 AM
kaasgaard kaasgaard is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2000
Location: Aalborg, Denmark
Posts: 36 kaasgaard User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to kaasgaard
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

Reply With Quote
  #4  
Old March 31st, 2000, 03:42 AM
tony styles tony styles is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Posts: 10 tony styles User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.


Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignHTML Programming > dynamic fields


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway