Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8708937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:14:59+00:00 2026-06-13T04:14:59+00:00

Im vey new to php. How to pass the selected drop box value to

  • 0

Im vey new to php. How to pass the selected drop box value to next page url? I have something like this:-

<script language="javascript">
    function showMe(str)
    {
    document.getElementById('myDiv').innerHTML = 'You have selected :'+str;
    }   
    </script>
    <select id="ccrseid" name="ccrseid" onchange="showMe(this.value);">
   <option value="">Select</option>
    <option value="1">Computer Science</option>
    <option value="2">Engineering</option>
    <option value="3">Business</option>
    <option value="4">Education and Training</option>

   </select>
<div id="myDiv"></div>

</body>
    </html>
<a href="#"onclick="document.location.href='timer.php?selectvalue='+document.getElementById('myDiv').value">Submit</a> 

when i execute im getting “undefined” at the url .

http://localhost/timer.php?selectvalue=undefined

how do i solve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:15:00+00:00Added an answer on June 13, 2026 at 4:15 am

    With your question, there seems like there are two different outcomes you want to achieve; the first being that you want to pass the value of the <select> dropbox to the landing php page, while your example code suggests that you want to pass the <select> value with appending “You have selected :” to it.
    So basically – with the given information – there are two outcomes you want to achieve, the first being the final “GET” url being

    http://localhost/timer.php?selectvalue=1
    

    And the other with the “GET” url being

    http://localhost/timer.php?selectvalue=You%20have%20selected%20:1
    

    With the first outcome, using javascript is a bad way of approaching this, I suggest to you to use the standard html <form> tag to build your form and <input> instead of the <a> tag as a button

    <form action="timer.php" method="get">
      <select id="ccrseid" name="selectvalue" onchange="showMe(this.value);">
      <option value="">Select</option>
      <option value="1">Computer Science</option>
      <option value="2">Engineering</option>
      <option value="3">Business</option>
      <option value="4">Education and Training</option>
      </select>
      <input type="submit" value="Submit">
    <form>
    

    With the second solution, that being to print the <select> value into a div and send that data to the landing page with a <a> tag, what you need to do is to to change the link on the last line

    <a href="#"onclick="document.location.href='timer.php?electvalue='+document.getElementById('myDiv').value">Submit</a>
    

    to

    <a href="#"onclick="document.location.href='timer.php?electvalue='+document.getElementById('myDiv').innerHTML">Submit</a>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a HashMap and I'd like to iterate they key-value pairs in a
So, I am working in this page http://universidadedoingles.com.br/text-tabs/tabs-text.html As you guys can see, I
I have this small script that changes the background image with a fadein/out effect:
how i could control objects in fast report like text width or label caption
I've got a vey simple form with a grid of 16 labels, each of
I am inserting a vey big xml in the Sybase column which has type
I'm working on an SBT plugin where I'd like to zip up a directory.
when I am executing this on the command line: awk 'BEGIN{OFS=FS=,}$3~/^353/{print}' axeM10_20110510100219_59.DAT_353 >log it
received help with. Basically, this code is written in Java but I need it
Sometimes I want to add posts to my blog and I dont want them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.