for example:
I have a form with the option
<b><option name=test value=testvalue></b>

how can I add an variable and pass it on like:

users add another variable:
<b><input type=textfield name=variable value=newvar>
</b>
then the option will become
<b><option name=test value=testvalue&newvar></b>

I need the variable be passed to the option link upon clicking on the submit button of the form..

any help will be really appreciated, thanks.

    I think what you want to do is JavaScript, not PHP. But, here's what I think will work.

    <option name-"test" value="testvalue">
    <input type="text" name="variable" value="newvar">
    <input type="submit" onClick="test.value=test.value+'&'+variable.value">

    Did I not understanding the question? This seems sort of weird...

      Thanks for the response.. Since you asked, I'm gonna post the script that I use and what I need.. some of you might be sick of it since I have been asking about this with different approaches..but here it goes:

      <form name="doublecombo">

      <select name="example" size="1" onChange="redirect(this.options.selectedIndex)">
      <option selected>Manufacturer</option>

                  </select>
                  <br>
                  <br>
                  <select name="stage2" size="1">
                    <option selected>Models</option>
                  </select>
                </p>
                <p align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Made 
                  between year</font> <font size="2"> <br>
      
                  <input type="text" name="lyear" size="7" value="1900">
                  and</font> <font size="2"> 
                  <input type="text" name="uyear" size="7" value="2002">
                  </font> <br>
                  <br>
                  <input type="submit" name="submit" value="Search" onClick="go()">
                </p>

      <script>
      <!--

      var groups=document.doublecombo.example.options.length
      var group=new Array(groups)

      for (i=0; i<groups; i++)

      group=new Array()

      group[0][0]=new Option ('Models')
      <?


      $result13 = mysql_query("SELECT something here'", $db);


      while ($row13 = mysql_fetch_array($result13))
      {

      echo"group[13][$i]=new Option('$row13[made] - $row13[model]','ecs_database.php3?page=14&action=searchmodel&model=$row13[model]<b>&lyear=$lyear&uyear=$uyear'</b>)\n";
      $i++;
      }

      ?>


      var temp=document.doublecombo.stage2


      function redirect(x){
      for (m=temp.options.length-1;m>0;m--)
      temp.options[m]=null
      for (i=0;i<group[x].length;i++){
      temp.options=new Option(group[x].text,group[x].value)
      }
      temp.options[0].selected=true
      }

      function go(){
      creator.location=temp.options[temp.selectedIndex].value
      self.close()
      }
      //-->
      </script>

      </form>


      I have cut out some parts to make it neat.

      This form works great before I added in the INPUT fields and this <b>&lyear=$lyear&uyear=$uyear'</b> after the link URL..

      I was hoping that added the line can pass the variables entered by the users..but apparently It doesn't..

      all i got from the URL bar is something like:

      http://domain.com/script.php?blah=blah&<b>lyear=&uyear=</b>

      no values returned...

      Please help 🙂

      Thanks for your time.

        btw, I added the +'&'+lyear thing you adviced, but it didn't work.

        I added it behind the value in the javascript (buttom), then the script wont work.

          i know you can keep rack of variables using
          $HTTP_POST_VARS....read up on it

          if i understand what you are asking its this simple as the code below.. if not could you be more specific. you do not need javascript for this

          <?php

          $testvalue="5";

          echo " Initial value is $testvalue. enter a number greater that 0 or whatever<br>";
          echo "New variable is ".$newvar;

          echo "<form method='post' action=$PHP_SELF>";

          echo "<input type=textfield name=newvar>";

          echo "<input type=submit name=submit value=submit>";
          echo "</form>";

          echo "<select name=test>";

          echo " <option value=$testvalue+$newvar>$testvalue&$newvar";

          echo "</select>";

          ?>

            You misunderstood me.

            I have to use the double combo box script, and I can't use a POST method for the form since if I do, ALL variables (some junk, like the example) will be passed on to the URL and I don't want that.

            Hence, I thought the best way is to somehow include the INPUT field value in the javascript.

              i am pretty sure you can use $HTTP_POST_VARS
              to accomplish that.. nothing is sent to tyhe url

                Ok, I tried your method with method=post so many times, but the $newvar JUST WOULDNT pass on. it's always empty...

                can you give me some 'clue' as to how to use http_post_vars?

                I made the form (in form.php) method = post and action=script.php..

                then in the script.php. I have a select in a function like this:

                $result = mysql_query("SELECT * FROM $table WHERE newvar LIKE '.HTTP_POST_VARS[newvar].'");

                This only end up returning .. and if i remove them, i just get empty return again..

                IM StUCK on this for weeks.. someone please help me out.

                  Write a Reply...