SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Enthusiast BrooklynSpice's Avatar
    Join Date
    Jan 2009
    Location
    Brooklyn, NY
    Posts
    57
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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!!!

    Lauren

    Here is the html for the list:

    Code HTML4Strict:
    <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>
    </select>


    here is the JS:
    Code JavaScript:
    $('p#general').hide(); 
            $('#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:
    Code PHP:
    $msg = " Name: $name\n" .
     
        "Email:   $email\n" .
     
        "Phone:   $phone\n" .
     
        "$subject\n" .
     
        "Operating System:   $opsys\n" .
     
        "How did you hear about us?:   $hear\n" .
     
        "Promo Code:   $promo\n" .
     
        "Comments:   $description\n" . 
     
        "Join mailing list:   $mailing\n";


    __________________
    You know I love it when you talk techie to me!

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,608
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    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.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Enthusiast BrooklynSpice's Avatar
    Join Date
    Jan 2009
    Location
    Brooklyn, NY
    Posts
    57
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    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

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

    Thanks!

    Lauren
    You know I love it when you talk techie to me!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •