Menu

Multiple Select Check Boxes...

Help
Anonymous
2008-01-31
2013-06-03
  • Anonymous

    Anonymous - 2008-01-31

    Hi TNT,

    I'm currently using the latest version of the Form script and I have to say that I am very well pleased with it for the most part.  It does just about everything I need and I'm sure it could be made to do everything if I was a better programmer.  Anyways, here are a few questions I have with it that I hope you can help me with.  I appreciate any and all help and will repost back what my findings are after making the necessary changes to the form.

    Ok...  Basically I tried doing a multiple select drop down list by just testing with this for example in my code in form.html : <select class=mainForm multiple name=field_29 id=field_29><option value=''></option><option value="_____" selected>_____</option> with the rest of the option value following the selected one.

    As you can probably see that didn't work for outputting the various multiple selected options.  It did allow in the form to select the options I wanted using ctrl + left click, but what was outputted was only the last selected option.  You can probably explain to me why this is.  If you have example code I could use for doing a multiple select drop down list I would appreciate that example so I could then implement it into my form.

    I've read on other post here that you suggest using check boxes for multiple select.  Could you give me example code for the form.html to do multiple select check boxes which would output the various data selected for one field in the form...  For example:

    Say I had a field like this in my form:

    Pipe Type Needed:
    [ ] Standard
    [ ] Schedule 40
    [ ] 3" Standard
    [ ] 6"
    [ ] 8"
    [ ] 10"
    [ ] 12"

    And say they selected the following check boxes: Standard, 3" Standard, 8", and 12"

    So then it would output to my e-mail the following:

    Pipe Type Needed: Standard, 3" Standard, 8", 12"

    Like that on the one line in e-mail.

    Can you give me example code to do this in form.html and also what I would need in processor.php so this can be accomplished?

    I'm really comfortable editing code so it's no problem really.  As I generated a long form with the web generator one then moved all the fields around with the up and down arrows and was able to successfully sort it all out as well as delete and add necessary ones.  I also added other things into the form that I learned from the forum like the host I.P. and stuff like that so I'm pretty comfortable with coding.

    I would rather have multiple select drop down lists if that is possible, but if not then I will implement the multiple select check boxes if you feel that is a better way to go.

    Here is one more question about the code:

    I entered the following into my processor.php file as I wanted to get the host information and output that information on the e-mailed form as well.  My question for this is what do I need besides the following in order to output it to my e-mailed form?

    $rhost = $_SERVER['REMOTE_HOST'];

    The above is placed right below the following in processor.php file:
    $where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));

    I tried the following in the mail portion of the processor.php file:

    $_POST['$rhost'] <--- Just guessing but as you can see it did not work.

    Thank You TNT for helping others and myself with this awesome script.  I understand that you did not make the script, but for you to be providing all the help you do it is very much appreciated. =)

    Thanks also go out to those that did help to make the script. =)

    As well thanks go to the user base here who have asked a lot of questions that I would have asked and it has helped me to get a functioning form.

    Type more to you soon TNT...

                                     --- GRebel

     
    • TNTEverett

      TNTEverett - 2008-02-01

      Specifying a multiple select like you described creates an array.  When you then process it in the processor.php file you need to treat it as an array otherwise it will be not be processed properly and the result is that you only get one of the many selected options.  There are two ways to resolve this.
      1.) Treat each selection as a separate item.
      2.) Complete the array processing such that you check all options and display only those that have been selected. 

      These can be done with drop down menus or separately as I mentioned.  It's up to you how to present the selections but a check box and a multi-select array must be processed differently. 

      $_POST[] is used to get values from a form "submit" action.  Once the variables are set within the processor.php file the $_POST prefix becomes unnecessary.  In your example you set $rhost=$_SERVER['REMOTE_HOST']; so now every other time you need to use this variable you just use the $rhost and not $_POST['rhost'].

      There are many $_SERVER[] variables that are part of the PHP installation.  You can reassign them as you have done or you can use the $_SERVER[] variable name everywhere you need the value. 

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.