Results 1 to 5 of 5

Thread: [RESOLVED] recording values from [MM_jumpMenu]

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2009
    Posts
    156

    Resolved [RESOLVED] recording values from [MM_jumpMenu]

    HTML Code:
    <script type="text/JavaScript">
    <!--
    function MM_jumpMenu(targ,selObj,restore){ //v3.0
      eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
      if (restore) selObj.selectedIndex=0;
    }
    //-->
    </script>
    PHP Code:
    <select width="20" name="noMenu" onchange="MM_jumpMenu('parent',this,0)">
                  <?php $noNumbers 1; while($noNumbers<100){?>
                    <option value=""><?php echo $noNumbers?></option>
                  <?php $noNumbers++;}?>
                  </select><?php  echo $_REQUEST['noMenu']; ?>
    I'm trying to record what number some one has chosen from this drop down menu. any Idea on how I can improve this code?

    (I'm using the form the drop down box is on for somthing else and it is set to GET)
    Last edited by LingoOutsider; Jul 24th, 2009 at 04:00 AM.

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: recording values from [MM_jumpMenu]

    unless the form that this <select> is on is being submitted, then no, there isn't any conventional way for you to record the number. with ajax, I'm sure you could record the number when it changes with the onchange event, though I've no idea if this might even be beneficial?

    what exactly are you trying to accomplish?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2009
    Posts
    156

    Re: recording values from [MM_jumpMenu]

    I'm using php code to generate a list of Items (from a database) that can be added to or removed, each with a seperate cost box where the value is inserted by the user. I'm using 'GET' on the html form to send cost and item information to the url.

    I can insert a textbox to send item amounts to the url to call on but I'm trying to have a list / drop down box of 1 to 99 next to each item instead so I can group the items... [item 1 -5][item 6][item 7 -9] etc.

    This is so multiple items in my list can be grouped.

  4. #4
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: recording values from [MM_jumpMenu]

    edit: scratch everything I posted. I see what your little javascript does, and I'm not entirely sure I paid attention to that before.

    is this what you're trying to accomplish?

    http://davidmiles.ca/php/mmjumpmenu.php

    PHP Code:
    <script type="text/JavaScript">
    <!--
    function MM_jumpMenu(targ,selObj,restore){ //v3.0
      eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
      if (restore) selObj.selectedIndex=0;
    }
    //-->
    </script>
    <?php
      
    //my fake items. there are 7 total. this would be the item array from your database.
      
    $items = array(0123456);

      foreach(
    $items as $item => $value):
    ?>
    <select width="20" onchange="MM_jumpMenu('parent',this,0)">
    <?php
      
    //loop 1 - 99
      
    for($i 1$i 100$i++):

        
    $url "?"//URL

        //loop through our itemval and build our URL
        
    foreach($_GET['itemval'] as $k => $v){
          if(
    $k == $item) continue; //skip the current item because the user is about to select it, and we don't want our URL being longer than needed
          
    $url .= "itemval[{$k}]={$v}&";
        }
    ?>
      <option value="<?php echo $url?>itemval[<?php echo $item?>]=<?php echo $i?>"<?php if($_GET['itemval'][$item] == $i) echo ' selected="selected"'?>><?php echo $i?></option>
    <?php endfor; ?>
    </select>
    <?php endforeach; ?>
    <pre>
    <?php print_r($_GET); ?>
    </pre>
    now, the only thing is that if you have other stuff stored in your URL, you will need to compensate for that and add onto your URL that other stuff as well (otherwise, it would be lost)! this is where things could get messy, but it's definitely possible.
    Last edited by kows; Jul 27th, 2009 at 03:02 PM.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Mar 2009
    Posts
    156

    Re: recording values from [MM_jumpMenu]

    Thanks I Think I've got it

Posting Permissions

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



Click Here to Expand Forum to Full Width