Help with hide function

Hello all,

I have a form that uses POST to send the info to me. In the form, I have a drop down menu. I also have sub-menus that are visible or not based on which option is selected. For the sake of these sub-menus, I had to put a value to each option on the list so that I could use JS.

So here is the question: Is it possible to find a work around so that when the email is sent, the subject contains the item in the menu instead of its value and still be able to use the JS code? I tried to use the id attribute on the options instead of value, but then the JS doesn’t work. At first I thought it was the PHP and i posted there, but I think I need help with the JS part, since the PHP seems to fine.

Let me also note, that the code is otherwise working fine, so I only took out small portions for examples, I just want to get the subject part to look better for the sake of replies. Thank you so much in advance!!!


Here is the html for the list:

<label for="subject">Subject:</label>
<select id="subject" name="subject" size="1">
<option>Select One</option>
<option value="gen">General Question/Comment</option>
<option value="video">Request an Audio/Video Quote</option>
<option value="bill">Payments/Billing</option>
<option value="comp">Computer Service</option>
<option value="mmserv">Multimedia Service</option>
<option value ="foren">Forensic Service</option>
<option value="other">Other</option>

here is the JS:

        $('#subject').change(function() {
        var val = $(this).val();
        var hide = (val == 'gen') ? false : true;
        (hide == true) ? $('p#general').slideUp('slow') : $('p#general').slideDown('slow');

here is the php:

$msg = " Name: $name\
" .
    "Email:   $email\
" .
    "Phone:   $phone\
" .
" .
    "Operating System:   $opsys\
" .
    "How did you hear about us?:   $hear\
" .
    "Promo Code:   $promo\
" .
    "Comments:   $description\
" . 
    "Join mailing list:   $mailing\

Since the values are what gets passed to the server any changes you make in the \JavaScript will not really help if your visitor has JavaScript disabled.

Why not just put the same values as you have text so that you are not replying on anything in the JavaScript.

Alternatively do it in the PHP using a lookup table for the subjects where the value passed just indicates which of the full subject lines to use.


I like the idea of doing it the PHP, this way it is server side and won’t be disabled by anyone.

Any suggestions on a good place to look to learn lookup tables? I have never made one, but I am very interested to learn how. As you can see, I am no PHP pro either :slight_smile:

If I use the lookup table, all the values in the html and javascript can stay as they are, correct?