List Box value >> display text1,2,3,4,5 etc.

F

Fawke101

Hi there,

I need a page where a user selects a value from a menu/list box, and a
certain part of a form is dislpayed.
Ideally (probs the easiest way for me) is to create 1 form with all the text
boxes etc and then when a user selects a value from the initial list box the
relative boxes are dislpayed.

Any help or examples of this much appreciated.
Can you have subforms of a form? if so how could i disable/enable a sub form
upon selecting a list box value?

*********
<select name="lstType" id="lstType">
<option selected>Please select the value......</option>
<option value="val_1">value1</option>
<option value="val_2">value2</option>
<option value="val_3">value3</option>
<option value="val_4">value4</option>
</select>
*********

--
Thanks in advance

Fawke

Please remove ANTI and SPAM
from my email address before emailing me.

www.bradflack.com
 
B

Bob Barrows

Fawke101 said:
Hi there,

I need a page where a user selects a value from a menu/list box, and a
certain part of a form is dislpayed.
Ideally (probs the easiest way for me) is to create 1 form with all
the text boxes etc and then when a user selects a value from the
initial list box the relative boxes are dislpayed.

Any help or examples of this much appreciated.
Can you have subforms of a form? if so how could i disable/enable a
sub form upon selecting a list box value?

*********
<select name="lstType" id="lstType">
<option selected>Please select the value......</option>
<option value="val_1">value1</option>
<option value="val_2">value2</option>
<option value="val_3">value3</option>
<option value="val_4">value4</option>
</select>
*********

This will require client-side DHTML code, which is off-topic for this group.
Anything that requires something to happen in response to a user's action
without submitting anything back to the server is outside the purview of
ASP. In the future, look for groups with "dhtml" in their name, or post to
one of the .scripting.* newsgroups depending on the script language you wish
to use (jscript or vbscript - most likely it will be jscript).

To solve your issue, you will need to create some divs whose display
property is initially set to "none".

<div id=div1 style="display:none">
relevant textboxes
</div>
<div id=div2 style="display:none">
relevant textboxes
</div>
etc.

Modify your SELECT tag to set the onchange event to the function you will
use to show/hide the divs:
<select name="lstType" id="lstType"
onchange="return lstType_onchange();">

Create your event handler as follows:
<SCRIPT type="text/javascript">
function lstType_onchange()
{
/*there will likely be an easier way depending on what the option values
really are (you can probably parse the div id from the value) but
for the
sake of this example, I will use a switch:*/
switch (lstType.value)
{
case "val_1":
showDiv("div1")
break
case "val_2":
showDiv("div2")
break
case "val_3":
showDiv("div3")
break
case "val_4":
showDiv("div4")
break
}
}
function showDiv(pDiv)
{
var i, oDiv
var divs=new array("div1","div2", "div3","div4")
for (var i=0;i<3;i++)
{
oDiv=document.getElementById(divs)
oDiv.style.diplay = "none"
if (divs == pDiv) {oDiv.style.diplay = "block"}
}
}
</SCRIPT>

Please follow up with any questions in a client-side scripting group.

HTH,
Bob Barrows
 
R

Randy Webb

Bob said:
This will require client-side DHTML code, which is off-topic for this group.

<snip>

How is it "off-topic for this group" if its posted in
microsoft.public.scripting.jscript ? Which is where I read it from..
 
R

Roland Hall

in message : Bob Barrows wrote:
: > Fawke101 wrote:
: >
: >>I need a page where a user selects a value from a menu/list box, and a
: >>certain part of a form is dislpayed.
: >>Ideally (probs the easiest way for me) is to create 1 form with all
: >>the text boxes etc and then when a user selects a value from the
: >>initial list box the relative boxes are dislpayed.
: >>
: >>Any help or examples of this much appreciated.
: >>Can you have subforms of a form? if so how could i disable/enable a
: >>sub form upon selecting a list box value?
: >>
: >>*********
: >><select name="lstType" id="lstType">
: >><option selected>Please select the value......</option>
: >><option value="val_1">value1</option>
: >><option value="val_2">value2</option>
: >><option value="val_3">value3</option>
: >><option value="val_4">value4</option>
: >></select>
: >>*********
: >
: >
: > This will require client-side DHTML code, which is off-topic for this
group.
:
: <snip>
:
: How is it "off-topic for this group" if its posted in
: microsoft.public.scripting.jscript ? Which is where I read it from..

Because it is cross posted and some of us read it in
m.p.inetserver.asp.general.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
F

Fawke101

Thanks for you responses guys, a great help.
I have divided the form into a group of tables, and i would like to display
the table in respect to which list box value is selected.

Will the Divs solution still apply? what exactly are Divs?

Thanks again people

--
Thanks in advance

Fawke

Please remove ANTI and SPAM
from my email address before emailing me.

www.bradflack.com
 
B

Bob Barrows

Fawke101 said:
Thanks for you responses guys, a great help.
I have divided the form into a group of tables, and i would like to
display the table in respect to which list box value is selected.

Will the Divs solution still apply? what exactly are Divs?
Please remove the asp group from your crosspost. This has nothing to do with
asp.

(Follow-Ups set to microsoft.public.scripting.jscript)
Bob Barrows
 
F

Fawke101

my apologies....... i will continue to post in the JS newsgroup

--
Thanks in advance

Fawke

Please remove ANTI and SPAM
from my email address before emailing me.

www.bradflack.com
 
B

Bob Barrows

Fawke101 said:
Thanks for you responses guys, a great help.
I have divided the form into a group of tables, and i would like to
display the table in respect to which list box value is selected.

Will the Divs solution still apply? what exactly are Divs?

Thanks again people

Same solution: only set the tables' id property and use it to set their
display properties instead of the divs'.

Bob Barrows
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top