Problem with storing data for mult selection and submit

Javascript coding ..

Moderators: macek, egami, gesf

szms
New php-forum User
New php-forum User
Posts: 10
Joined: Thu Jun 26, 2003 7:42 am

Problem with storing data for mult selection and submit

Postby szms » Wed Aug 13, 2003 4:53 am

I am trying to get the user selection after all menu has been shown to the user and when the selections are done. Could you please let me know how to get all those information at the end. The way I did it just work for the last menu selection. I suppose I have to use some sort of array but don't know exactly how to do that. I will appriciate your suggestion. Thank you.

Take a look of my complete code:

Code: Select all

<html>
<title>
Menu test
</title>
<body>
<script type="text/javascript">
<!--
function updateTextBox(selectObj, textBoxObj)
{
    var index = selectObj.selectedIndex;
    var selection = selectObj.options[index].text;
    textBoxObj.value += selection + "\n";
}
// -->
</script>
<!-- <form name = "myform" action="CheckInsertedItems.php" method="POST"> -->
<?php
extract( $_GET );

if( !isset($submit))// do this if no GET vars
{
    print "<form method=\"GET\">";
    print "<p>Enter in the number of times below:</p>";
    print "<input type=\"text\" name=\"number\" size=\"30\">";
    $menu_counter = 0;
    print "<input type='hidden' name='menu_counter' value=$menu_counter>";
    print "<input name=\"submit\" type=\"submit\" value=\"send\">";
    print "<input name=\"reset\" type=\"reset\" value=\"reset\">";
    print "</form>" ;
}
else
{

    if( $number>0 )
    {
        $months = array("January","February","March","April","May","June","July",  "August","September","October","November","December");

        $number = $HTTP_GET_VARS["number"]-1;
        $menu_counter =$HTTP_GET_VARS["menu_counter"]+1;
        print "<form   method=\"GET\">";
        print "Select components for term $menu_counter<br>";
?>
        <select size="5" name="user_choice" onclick="updateTextBox(this, currentSelections)"><?php
        foreach ($months as $Existing_Item)
        {
            print "<option value=\"$Existing_Item \">$Existing_Item</option>";
        }
        print "</select>";
        print "<br>";
?>
        <select size="5" name="user_choice" onclick="updateTextBox(this, currentSelections)">
        <?php
        foreach ($months as $Existing_Item)
        {
            print "<option value=\"$Existing_Item \">$Existing_Item</option>";
        }
        print "</select>";
        print "<br>";
        ?>
        <textarea name = 'currentSelections' readonly="readonly" rows = "3" cols = "20"></textarea>
        <br>
<?php


---Trying to store selected items ----------
//$Selected_Array[] = $currentSelections;

print "<input type='hidden' name='Selected_Array[]' value=$currentSelections>";



Code: Select all

print "<input type='hidden' name='number' value=$number>";
        print "<input type='hidden' name='menu_counter' value=$menu_counter>";
        print "<input name=\"submit\" type=\"submit\" value=\"submit\">";
        print "<input name=\"reset\" type=\"reset\" value=\"reset\">";
        print "</form>";
    }
    else
    {
        // do whatever happens after the number of forms has been filled



---Trying to show all selected items ----------
print "<br>You choice are: <br>";
$Selected_Array = $HTTP_GET_VARS["Selected_Array"];
foreach($Selected_Array as $name)
{
print "$name";
}



Code: Select all


}
}

?>
</body>
</html>


User avatar
swirlee
Moderator
Moderator
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Postby swirlee » Wed Aug 13, 2003 8:08 am

Please don't cross-post. The likelihood of your question getting answered varies inversely with the number of times you post it.

szms
New php-forum User
New php-forum User
Posts: 10
Joined: Thu Jun 26, 2003 7:42 am

Solution please !!!!!!!!!!!

Postby szms » Wed Aug 13, 2003 8:31 am

Well, is there anyone who can help me regarding the problem that I posted. Thank you.


Return to “JavaScript”

Who is online

Users browsing this forum: No registered users and 1 guest

cron