Jump to content

not getting <input type=hidden> value thru $_GET


helloise

Recommended Posts

i have the following code:

            <li>Have you read the <?php echo link_to('FAQ','util/faq') ?> ?

                <select id="yesnolist" onChange="getChoice(this.value)">

                    <option value="yes" selected="selected">Yes</option>

                    <option value="no">No</option>

                </select>

            </li>   

            <input type="hidden" name="text" size=30 id="yesandno">

            <?php

                if ($_GET['yesandno'] == "no")

                {

                  echo "anything!!!!!!!!!!!!!!!!!!!";

                }

            ?>

 

then my java script for getCoice():

function getChoice(val)

  {

      yesNo = new Array("Yes", "No");

      var getsel = document.contactus.yesnolist.value;

      var e = document.getElementById("yesnolist");

      var strUser = e.options[e.selectedIndex].value;

     

      document.contactus.yesandno.value = strUser;

      alert(document.contactus.yesandno.value);

      return strUser;

  }

 

my alert will gove yes or no depending on what i chose in the dropdown

but HOWCOME it does not go into the if  ($_GET['yesandno'] == "no") ????

 

please help???

 

Link to comment
Share on other sites

It sounds like your expecting something to happen to the page once getChoice() is activated. If that's the case, the problem is you're mixing client-side and server-side scripting which won't work.

 

If you want the page to display something without reloading, you'll need to stick with a language like JavaScript. Otherwise, to use PHP you'll need to submit the form back to the server and display the page again with the desired results.

Link to comment
Share on other sites

thanks i've changed my code a bit now, i have my JS like this now:

<script type="text/JavaScript">

  function getChoice(val)

  {

      yesNo = new Array("Yes", "No");

      var getsel = document.contactus.yesnolist.value;

      var e = document.getElementById("yesnolist");

      var strUser = e.options[e.selectedIndex].value;

      if (strUser == "no")

      {

          //go the the faq page here

      }

      return strUser;

  }

 

then my html looks like this now:

<div>   

<tr></tr>

<tr></tr> 

<tr>

<td colspan='3' align='left' class='small_header_rbc'>

        <h3>Frequently Asked Questions</h3>

    <li>Please take a moment to read the Frequently Asked Questions as the solution to your query could be waiting for you there!</li>

            <li>Have you read the <?php echo link_to('FAQ','util/faq') ?> ?

                <select id="yesnolist" onChange="getChoice(this.value)">

                    <option value="yes" selected="selected">Yes</option>

                    <option value="no">No</option>

                </select>

            </li>   

    </tr> 

    <tr></tr> 

    <tr></tr> 

</div>

 

so i was thinking maybe i can make a call to the FAQpage in the JS when no is selected in my dropdown???

can someone help on how to do this please?

thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.