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 9108835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:53:54+00:00 2026-06-17T02:53:54+00:00

Noob here trying to do something simple with Jquery. Basically I have a small

  • 0

Noob here trying to do something simple with Jquery. Basically I have a small select-option dropdown like this:

<select onchange="javascript:swapContent('con3');">
    <option>selection 1</option>
    <option>selection 2</option>
    <option>selection 3</option>
</select>

Currently it is posted via ajax to a $php variable here:

$contentVar = $_POST['contentVar'];

javascript function is here:

<script language="JavaScript" type="text/javascript">
function swapContent(cv) {
    $("#myDiv").html('<img src="loader.gif"/>').show();
    var url = "myphpscript.php";
    $.post(url, {contentVar: cv} ,function(data) {
        $("#myDiv").html(data).show();
    });    
}
</script>

How can I instead post the value of the select-option dropdown?

I realize this is basic, but I have to start somewhere and cannot find a tutorial that shows me how to do what I need. Thank you for your help.

  • 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-17T02:53:56+00:00Added an answer on June 17, 2026 at 2:53 am

    How can I instead post the value of the select-option dropdown?

    If you want to send values yo tour script you should start by giving values to your option elements (and an id to your <select> element to be able to use it and retrieve the selected value):

    <select onchange="javascript:swapContent('con3');" id="myselect">
        <option value="value1">selection 1</option>
        <option value="value2">selection 2</option>
        <option value="value3">selection 3</option>
    </select>
    

    and then:

    // get the currently selected value from the dropdown
    var value = $('#myselect').val();
    $.post(url, { contentVar: cv, selectedValue: value }, function(data) {
        $("#myDiv").html(data).show();
    });
    

    If on the other hand you wanted to send the text of the selected option you could use this:

    // get the currently selected value from the dropdown
    var text = $('#myselect option:selected').text();
    $.post(url, { contentVar: cv, selectedText: text }, function(data) {
        $("#myDiv").html(data).show();
    });
    

    Now inside your PHP script you could fetch the value:

    $_POST['selectedValue']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Total noob here with javascript. I'm trying to alter a function. This is the
Rails noob here. I have a rails application with (in this example) three tables.
jQuery noob here (don't most posts start like that?) I know I could do
A noob here. I have a model class where I want to save something
javascript noob trying to figure something out. I saw a script located here: Using
Noob here trying to figure out the simple task of adding a page to
Let's say I have something like this in a file named main.js : function
Noob here learning backbone.js. I was trying to create a simple horizontal menu (each
this may sound like a strange question from a Python noob, but here's the
I am trying to figure out how to rewrite URLs from something like this:

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.