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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:11:33+00:00 2026-05-25T10:11:33+00:00

I also want a listbox with multiple selection to use along with the above

  • 0

I also want a listbox with multiple selection to use along with the above code, but its not working

$cnty is the variable (listbox – multiselection).

Below is my complete ajax function used .

<script language="javascript" type="text/javascript">


function ajaxFunction(){
    var ajaxRequest;  // The variable that makes Ajax possible!

    try{
        // Opera 8.0+, Firefox, Safari
        ajaxRequest = new XMLHttpRequest();
    } catch (e){
        // Internet Explorer Browsers
        try{
            ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try{
                ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e){
                // Something went wrong
                alert("Your browser broke!");
                return false;
            }
        }
    }
    // Create a function that will receive data sent from the server
    ajaxRequest.onreadystatechange = function(){
        if(ajaxRequest.readyState == 4){
            //document.myForm.time.value = ajaxRequest.responseText;
            document.getElementById("result").innerHTML=ajaxRequest.responseText

        }
    }

    var dav = document.getElementById('dav').value;
    var pathogen = document.getElementById('pathogen').value;
    var topic1 = document.getElementById('topic1').value;
    var ind1 = document.getElementById('ind1').value;
    var subindg1 = document.getElementById('subindg1').value;
    var cnty = document.getElementById('countryRF').value;

    var queryString = "?dav=" + dav + "&pathogen=" + pathogen + "&topic1=" + topic1 + "&ind1=" + encodeURIComponent(ind1) + "&subindg1=" + encodeURIComponent(subindg1) +  "&cnty=" + encodeURIComponent(cnty);
    ajaxRequest.open("GET", "sortby.php" + queryString, true);
    ajaxRequest.send(null);
}


</script>

sortby.php page

<?php

                                $con = mysql_connect("localhost","root","adminpp");
                                mysql_select_db("pdata", $con);
$datav=$_GET["dav"];
$pathogen=$_GET["pathogen"];
$topic1=$_GET["topic1"];
$ind1=$_GET['ind1'];
$subindg1=$_GET["subindg1"];
$cnty=$_GET['cnty'];



echo $subindg1;
echo $cnty;

?>
  • 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-05-25T10:11:34+00:00Added an answer on May 25, 2026 at 10:11 am

    There’s a variety of ways to pass a multiselect list to the server through Ajax. This is just one of many… and probably not even the best. 🙂

    I’m going to use the variable name multisel throughout so you can find it easily and see how to use it.

    Add this function to your javascript

    function loopSelected(selObj)
    {
        var selectedArray = new Array();
        var i;
        var count = 0;
        for (i=0; i<selObj.options.length; i++) {
            if (selObj.options[i].selected) {
                selectedArray[count] = selObj.options[i].value;
                count++;
            }
        }
        return selectedArray;
    }
    

    Now, add the following lines to ajaxFunction just after your variables.

    var selObj = document.getElementById('multistore');
    
    var multisel = loopSelected(selObj).join('~');  // join array into a string
    

    Finally, in PHP, add these lines

    $multisel = $_GET['multisel'];
    $multisel_array = explode('~',$multisel);   // split the items into an array
    
    var_dump($multisel_array);
    

    At this point all of the selected items are in $multisel_array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListBox and want the selection-mode to be extended. Also I want
I am adding items to a ListBox like so: myListBox.Items.addRange(myObjectArray); and I also want
I want to implement a function in the base class but I also want
i use java reflections to get methods used in a class.I also want to
I'd like to give customers a choice of the database engine, but also want
I'm using Apache Commons Logging and SLF4J with log4j, but I also want to
So I have this code to change the background selection colour of a listbox
i want to save current date+time into database and also want to retrieve it.
I want to set the height of asp:panel to auto and I also want
i want to call a batch file from another batch file and also want

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.