Page 1 of 1

How to differentiate items from two menu and every submissio

Posted: Thu Aug 14, 2003 7:57 am
by szms
Please have a carefull look of my code. I am trying to differentiate the items after the final submission so that I have all items for each submission togather and those item must be identified whether it comes from top menu or the bottom menu.

Suppose user chose 2 and then press submit. Now for first time user chose January and March from the top menu and March from the bottom menu and hit submit. Now in second time user select April from Bootm Menu and hit submit. After getting the output items from all submission I want to store those in a MYSQL Database. The order of the selected items for each submission is also important.

Expected output:

First time: January(1) from Top Menu.
March(2) from Top Menu.
March(3) From Bottom Menu.

Second Time: April(1) from Bottom Menu

Please let me know if you have some idea how to do that. Thank you.

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"> --> 
<pre> 
<?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( $submit=='submit' ) 
    { 
        $results[] = $currentSelections; 
    } 

    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 

     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">"; 

     $i=0; 
     if( isarray( $results ) ) 
     foreach( $results as $res ) 
     { 
         echo "<input type='hidden' name='results[$i]' value='$res'>"; 
         $i++; 
     } 
     print "</form>"; 
  } 
  else 
  { 
      print "<br>You choice are: <br>"; 
      $Selected_Array = $results; 
      foreach($Selected_Array as $name) 
      { 
          print "$name<BR>"; 
      } 
   } 
} 

?> 
</body> 
</html>

Posted: Thu Aug 14, 2003 11:18 am
by McGruff
Please post basic questions in the normal forum. The advanced forum is for more theoretical matters.

Posted: Thu Aug 14, 2003 11:40 am
by szms
Thank you for your reply. I thought the problem I am facing is for advanced programmer. So if is there anyone who has some idea how to solve this, I will appriciate it. Thank you.

Posted: Fri Aug 15, 2003 7:44 am
by twigletmac
There are advanced programmers in the PHP - Normal forum, which is where you should look for answers to how to type questions. The Advanced forum, which is not limited to advanced programmers, is for design/theory discussions. Hence your topic has been moved.

Mac