![]() |
Show all 5 posts from this thread on one page |
VCDQuality Forums (http://www.vcdhq.com/forum/index.php)
- Computer and Audio/Video help (http://www.vcdhq.com/forum/forumdisplay.php?forumid=56)
-- Small bit of Java Script required (http://www.vcdhq.com/forum/showthread.php?threadid=74552)
Small bit of Java Script required
I'm looking for a small bit script that is made up of a form [Select] tag and an [textarea] tag.
I would like the contents of the textarea to be non modifiable, but change depednding on which option within the Select tag is picked.
e.g Select pull down menu with items
2007
2008
2009
2010
The the text area displaying "2007 - A good year for pizza, beer and football" when 2007 is selected, "2008 - A good year for pasta, wine and movies" when 2008 is selected and so on.
(BTW, the task I will use it for has nothing to to with dates, but it seemed the easiest example).
I'm sure this is probably easy to do, but I cant seem to select the right keywords for a google search as it comes up empty.
Cheers
Re: Small bit of Java Script required
Tested and working
code:
<form id="form"> <textarea name ="form[textarea]" id="formTextarea" READONLY></textarea> <select id="formSelect" name="form[select]" onchange="document.getElementById('formTextarea').innerHTML=this.options[this.selectedIndex].value;"> <script type="text/javascript"> var select = new Array(5); select[0] = "2005"; select[1] = "2006"; select[2] = "2007"; select[3] = "2008"; select[4] = "2009"; for (var x = 1; x < 5; x++) { document.write("<option value = '" + select[x] + "'>" + select[x] + "</option>\n"); } </script> </form>
__________________


i have sigs off 
:edit: I was asking a bit much in this post. Running before I could walk, the next post down has a much simpler request, that once I get right should be easy to expand. :edit:
Thanks for the code Dwaggy, it does work well, but isn’t quite what I need.
In my actual brief the different selections with the <Select> statement should produce radical difference in the <textarea>. Meaning a one word select option may need to produce a paragraph of text.
I have used the code on this page http://www.felgall.com/jstip22a.htm to create 2 select options.
Select1 and Select2, with Select2 options dynamically changing depending on which option is picked in Select1.
The only problem being is that I need a <textarea> to dynamically change when different options are picked within select2.
The end user should pick an option in select1, this will limit the options available in select2. When something is then picked from select2 the text area should produce a paragraph displaying the details of the select2 option.
The code I have works, with select2 being dynamically created from select1, but what I need now is for textarea to by dynamically created from select2.
I wish I could explain it a bit better, but hopefully you get the idea.
Any idea how I would go about it?
Bit more practical information.
quote:
function menupick(chosen)
{
if (chosen == "Foo")
{
document.my_form.my_text_area.defaultValue[="here is the information for item Foo"]
}
if (chosen == "Bar")
{ document.my_form.my_text_area.defaultValue[="here is the information for item Bar"]
}
}
quote:
<form name=my_form>
<select name="my_select_menu" size="1" onchange="menupick(document.my_form.my_select_menu.options[document.my_form.my_select_menu.selectedIndex].value);">
<option value="Foo">Item Foo</option>
<option value="Bar">Item Bar</option>
<TEXTAREA name="my_text_area" READONLY rows="10" cols="60"></TEXTAREA>
quote:line is wrong but dont know how to fix.
document.my_form.my_text_area.defaultValue[=" blah blah"]
Fixed it,
quote:
document.my_form.my_text_area.value = "blah blah"
| All times are GMT. The time now is 01:12 PM. | Show all 5 posts from this thread on one page |
Powered by: vBulletin Version 2.3.0
Copyright © Jelsoft Enterprises Limited 2000 - 2002.