SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict ibeblunt's Avatar
    Join Date
    Jan 2001
    Location
    Jersey City, NJ
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What Am I Missing In My Form?

    I have a form which has 3 drop down menus.

    The first list, is a list of pre-populated groups that I can send e-mails to.
    So let's say I have 5 groups: HTML GROUP, CSS GROUP, PHP GROUP, XML GROUP, MYSQL GROUP.

    The second list is blank, but it's will contain the groups of people I want to send e-mails to. So let's say I want to send an e-mail to only the HTML GROUP and the PHP GROUP. I'd click the SEND GROUP and the second drop down menu would be populated.

    The third list is blank, but it's a list of people that I to exclude from receiving the e-mail. So let's say I don't want people on the XML GROUP to get this e-mail, I'd click the EXCLUDE GROUP and the third drop down menu would be populated.

    THIS ALL WORKS JUST FINE...

    The problem is when the user hits submit. I wrote a function called displayArray (see below) to help me display an array. I pass it the $_POST and I notice that none of the drop down menus are in the array.

    PHP Code:
    function displayArray($array) {
    if (
    $array) {
    ksort($array);
    echo 
    '<table width="500" border="1" cellspacing="1" cellpadding="3">';
    foreach (
    $array as $key => $value) {
    echo 
    '<tr><td width="25%"><b>' $key '</b></td><td width="75%">' $value '</td></tr>';
    }
    echo 
    '</table>';
    }
    return;

    All the other variables in the form are passed EXCEPT the drop down menu variables. I know for certain that each drop down menu has a name:

    HTML Code:
    <select
    id="send_group_SELECT"
    multiple
    name="send_group_SELECT"
    onDblClick="move(this.form.send_group_SELECT,this.form.send_group_CHOICE);"
    size="10"
    style="width: 150px;">...</select>
    
    <select
    id="send_group_CHOICE"
    multiple
    name="send_group_CHOICE"
    onDblClick="move(this.form.send_group_CHOICE,this.form.send_group_SELECT);"
    size="10"
    style="width: 150px;"></select>
    
    <select
    id="send_group_EXCLUDE"
    multiple
    name="send_group_EXCLUDE"
    onDblClick="move(this.form.send_group_EXCLUDE,this.form.send_group_SELECT);"
    size="10"
    style="width: 150px;"></select>
    You can see the HTML code here. http://www.sohh.com/menu_test.html

    When you press submit, you'll be presented with all of the $_POST variables.

    Any help will be appreciated.
    <///////~

    www.sohh.com

  2. #2
    SitePoint Addict ibeblunt's Avatar
    Join Date
    Jan 2001
    Location
    Jersey City, NJ
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah ha!

    It appears that even though the names and values get transfered over, they aren't selected. If I select them by highlighting them, the values appear.

    So what should I do now?
    <///////~

    www.sohh.com

  3. #3
    SitePoint Addict ibeblunt's Avatar
    Join Date
    Jan 2001
    Location
    Jersey City, NJ
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, I'm one step closer to figuring this out.

    What I did was write a javascript that will select the second and third drop down menus upon pressing submit.

    It works but it doesn't.

    Here's the script:

    Code:
    <script language="JavaScript" type="text/javascript">
    <!--
    	function submitForm() {
    		var choice = document.alerts.send_group_CHOICE.length;
    		var exclude = document.alerts.send_group_EXCLUDE.length;
    		
    		alert('Choices:' + choice);
    		
    		alert('Exclusions:' + exclude);
    		
    		if (choice) {
    			for (i = 0; i < choice.length; i++) { 
    				choice.options[i].selected = true; 
    			}
    		}
    		
    		if (exclude) {
    			for (i = 0; i < exclude.length; i++) { 
    				exclude.options[i].selected = true; 
    			}
    		}
    
    		return true;
    
    	}
    //-->
    </script>
    Everything up to the alerts works. It sees that I have made choices and sees that I have made exclusions, but it will not automatically select them. I'm sure it's something simple.
    <///////~

    www.sohh.com

  4. #4
    SitePoint Addict ibeblunt's Avatar
    Join Date
    Jan 2001
    Location
    Jersey City, NJ
    Posts
    312
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I got it!

    The solution was:

    Code:
    	
    if (choice) {
    	for (i = 0; i < choice; i++) { 
    		document.alerts.send_group_CHOICE.options[i].selected = true; 
    	}
    }
    		
    if (exclude) {
    	for (i = 0; i < exclude; i++) { 
    		document.alerts.send_group_EXCLUDE.options[i].selected = true; 
    	}
    }
    
    return true;
    I guess I have no one to thank but me. So, thanks ibe.

    You're welcome.
    <///////~

    www.sohh.com


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
  •