Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Select help please

Reply
Thread Tools

Select help please

 
 
Boyd Reilly
Guest
Posts: n/a
 
      01-03-2004
I'm pretty new to this stuff, so any help is welcome.

I have a select list as follows:
<select name= "CHDRUGTYPE">
<option value="1">Beer</option>
<option value="2">Wine</option>
<option value="3">Hard Liquor</option>
<option value="4">Illegal Drugs</option>
</select>
On that same page I have another select list. However, I want this list to
be refelective of what is chosen in the first list. Thus, if Option1 is
chosen I want the second list to be:

<select name= "CHDRUG">
<option value="1">Becks</option>
<option value="2">Sam Adams</option>
</select>

If Option 2 is chosen I want the second list to be:
<select name= "CHDRUG">
<option value="1">Thunderbird</option>
<option value="2">Mad Dog</option>
</select>

I don't know how to change the second list after the first list is chosen.

As said, I'm pretty new to this stuff, so any help is more than welcome.

Thanks for the help.

Boyd


 
Reply With Quote
 
 
 
 
Leif K-Brooks
Guest
Posts: n/a
 
      01-03-2004
Boyd Reilly wrote:
> On that same page I have another select list. However, I want this list to
> be refelective of what is chosen in the first list.


Have the second list on a server-generated page which changes it.

 
Reply With Quote
 
 
 
 
Boyd Reilly
Guest
Posts: n/a
 
      01-03-2004
I appreciate the help, Leif, but you are talking over my head here. Keep in
ming,I need everything to be on the same page. If you could, can you post
codeof what needs to be done.

TIA.

Boyd

"Leif K-Brooks" <(E-Mail Removed)> wrote in message
news:yYqJb.692$(E-Mail Removed)...
> Boyd Reilly wrote:
> > On that same page I have another select list. However, I want this list

to
> > be refelective of what is chosen in the first list.

>
> Have the second list on a server-generated page which changes it.
>



 
Reply With Quote
 
Leif K-Brooks
Guest
Posts: n/a
 
      01-03-2004
Boyd Reilly wrote:
> I appreciate the help, Leif, but you are talking over my head here. Keep in
> ming,I need everything to be on the same page. If you could, can you post
> codeof what needs to be done.


In PHP:
if (empty($_POST['CHDRUGTYPE'])) {
firstform();
}
switch ($_POST['CHDRUGTYPE']) {
case 1:
# Display the select list for option 1
break;
case 2:
# Select list for option 2
break;
default:
firstform();
}
function firstform() {
// Display a form with the first select list
}

 
Reply With Quote
 
Boyd Reilly
Guest
Posts: n/a
 
      01-03-2004
I appreciate your patience with me. But, when I add that code it
doesnothing but to add more unwanted tet to the screen. Please try this and
tell me where I go wrong:

<select name= "CHDRUGTYPE">
<option value="1">Beer</option>
<option value="2">Wine</option>
<option value="3">Hard Liquor</option>
<option value="4">Illegal Drugs</option>
</select>

<select name= "CHDRUG">
<option value="1">Becks</option>
<option value="2">Sam Adams</option>
</select>


<select name= "CHDRUG">
<option value="1">Thunderbird</option>
<option value="2">Mad Dog</option>
</select>

if (empty($_POST['CHDRUGTYPE'])) {firstform()} switch ($_POST['CHDRUGTYPE'])
{case 1: # Display the select list for option 1 break; case 2: # Select list
for option 2 break; default: firstform(); } function firstform() {// Display
a form with the first select list}

Boyd
"Leif K-Brooks" <(E-Mail Removed)> wrote in message
news:eRrJb.694$(E-Mail Removed)...
> Boyd Reilly wrote:
> > I appreciate the help, Leif, but you are talking over my head here.

Keep in
> > ming,I need everything to be on the same page. If you could, can you

post
> > codeof what needs to be done.

>
> In PHP:
> if (empty($_POST['CHDRUGTYPE'])) {
> firstform();
> }
> switch ($_POST['CHDRUGTYPE']) {
> case 1:
> # Display the select list for option 1
> break;
> case 2:
> # Select list for option 2
> break;
> default:
> firstform();
> }
> function firstform() {
> // Display a form with the first select list
> }
>



 
Reply With Quote
 
Fredo Vincentis
Guest
Posts: n/a
 
      01-03-2004
"Boyd Reilly" <(E-Mail Removed)> wrote in message
news:3ff64e79$0$6766$(E-Mail Removed)...
> I appreciate your patience with me. But, when I add that code it
> doesnothing but to add more unwanted tet to the screen.


Leif's code is the best solution to your problem, but it requires your
website to run on a server that supports server-side scripting. You get the
extra text on the screen, because you are putting PHP code into a HTML file.

If you have got lots of different options that are going into the SELECT
fields, you might be doing good in learning a bit of PHP in addition to the
HTML you already know. But if you have only got one or two selection boxes
with a few entries each, this link might help you to achieve what you want:

http://www.acmesoffware.com/acme/Exa...ateSelects.asp

It is an intro on how to dynamically populate select boxes using javascript.
All you have to do is copy and paste the code into your HTML document (the
form code into the <body>, the javascript into the <head>) and make the
appropriate changes to the entries.

In order to change the javascript in the link above, all you have to do is
change the value of the <option> tags to whatever you want. E.g. Beer, Wine,
Hard Liquor, etc. Then in the javascript, you will notice that there are
lines that currently say:

case "Item1" :

and

case "Item2" :

Change those lines to what you wrote into your option values. For example:

case "Beer" :

case "Wine" :

etc.

Finally, enter the new options you want in your selection box under each of
the "cases". Currently they have got label A1, label A2, etc.

If you have difficulties with it, let me know.


 
Reply With Quote
 
Leif K-Brooks
Guest
Posts: n/a
 
      01-03-2004
Fredo Vincentis wrote:
> http://www.acmesoffware.com/acme/Exa...ateSelects.asp


Oh &deity;, not one of those! How on earth am I supposed to fill out
your form without JavaScript? Since the OP was using a form, some type
of server-side scripting must be available. Use that.

 
Reply With Quote
 
Fredo Vincentis
Guest
Posts: n/a
 
      01-03-2004
"Leif K-Brooks" <(E-Mail Removed)> wrote in message
news:lstJb.700$(E-Mail Removed)...
> Fredo Vincentis wrote:
> > http://www.acmesoffware.com/acme/Exa...ateSelects.asp

>
> Oh &deity;, not one of those! How on earth am I supposed to fill out
> your form without JavaScript? Since the OP was using a form, some type
> of server-side scripting must be available. Use that.


You seem to forget that it takes a bit to learn server-side scripting. Not
everybody has got the time or the technical skill to learn ASP or PHP. As I
said: I agree it's the right solution, but javascript may be the way to go
for Boyd (depends on what his site is trying to achieve).


 
Reply With Quote
 
Boyd Reilly
Guest
Posts: n/a
 
      01-03-2004
Fredo:

Thanks for thehelp. I will give it a shot.

Boyd

"Fredo Vincentis" <(E-Mail Removed)> wrote in message
news:bt5lls$cn7$(E-Mail Removed)...
> "Boyd Reilly" <(E-Mail Removed)> wrote in message
> news:3ff64e79$0$6766$(E-Mail Removed)...
> > I appreciate your patience with me. But, when I add that code it
> > doesnothing but to add more unwanted tet to the screen.

>
> Leif's code is the best solution to your problem, but it requires your
> website to run on a server that supports server-side scripting. You get

the
> extra text on the screen, because you are putting PHP code into a HTML

file.
>
> If you have got lots of different options that are going into the SELECT
> fields, you might be doing good in learning a bit of PHP in addition to

the
> HTML you already know. But if you have only got one or two selection boxes
> with a few entries each, this link might help you to achieve what you

want:
>
> http://www.acmesoffware.com/acme/Exa...ateSelects.asp
>
> It is an intro on how to dynamically populate select boxes using

javascript.
> All you have to do is copy and paste the code into your HTML document (the
> form code into the <body>, the javascript into the <head>) and make the
> appropriate changes to the entries.
>
> In order to change the javascript in the link above, all you have to do is
> change the value of the <option> tags to whatever you want. E.g. Beer,

Wine,
> Hard Liquor, etc. Then in the javascript, you will notice that there are
> lines that currently say:
>
> case "Item1" :
>
> and
>
> case "Item2" :
>
> Change those lines to what you wrote into your option values. For example:
>
> case "Beer" :
>
> case "Wine" :
>
> etc.
>
> Finally, enter the new options you want in your selection box under each

of
> the "cases". Currently they have got label A1, label A2, etc.
>
> If you have difficulties with it, let me know.
>
>



 
Reply With Quote
 
David Dorward
Guest
Posts: n/a
 
      01-03-2004
Fredo Vincentis wrote:

> You seem to forget that it takes a bit to learn server-side scripting.


It also takes a bit to learn client-side scripting. One is dependable and
useful for essential functionality, one is undependable and useful for
optional extras.

> Not everybody has got the time or the technical skill to learn ASP or PHP.


or JavaScript.

--
David Dorward <http://dorward.me.uk/>
 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please please please help this guy with his open source java app casioculture@gmail.com Java 4 05-05-2005 08:24 AM
Computer problems please please please help Nick Computer Support 0 06-04-2004 08:49 PM
HELP! HELP! PLEASE, PLEASE, PLEASE tpg comcntr Computer Support 11 02-15-2004 06:22 PM
select of select box will select multiple in another box palmiere Javascript 1 02-09-2004 01:11 PM
please help... ...me learn C++ please please please :) KK C++ 2 10-14-2003 02:08 PM



Advertisments