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

  • Home
  • SEARCH
  • 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 7844021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:44:58+00:00 2026-06-02T16:44:58+00:00

What I have is an that opens up a Jquery popup with a form

  • 0

What I have is an that opens up a Jquery popup with a form in it. This form has a with multiple options (you can select more than one at a time). I am trying to use a “countries” attribute of the to select multiple selections (see example below).

This WORKS:

<a href="#" id="openpop"> //The link

....
//The Popup HTML
<select id="countryselection" multiple="multiple">
<option>US</option>
<option>CA</option>
<option>GB</option>
</select>

....
//The event handler
$("#openpop").click(function(){
loadPopup();
("#countryselection").val(['US', 'CA']);
});

So the example above works fine…

This ALSO WORKS:

<a href="#" id="openpop" countries="US"> //The link with countries attribute

....
//The Popup HTML
<select id="countryselection" multiple="multiple">
<option>US</option>
<option>CA</option>
<option>GB</option>
</select>

....
//The event handler
$("#openpop").click(function(){
loadPopup();
("#countryselection").val([$(this).attr("countries"), 'CA']); //Notice the this.attr
});

The problem is, I need to set MULTIPLE countries, all from the countries attribute of the tag.

It doesn’t work when I try it…

This DOES NOT WORK:

<a href="#" id="openpop" countries="'US','CA'"> //The link with multiple countries

....
//The Popup HTML
<select id="countryselection" multiple="multiple">
<option>US</option>
<option>CA</option>
<option>GB</option>
</select>

....
//The event handler
$("#openpop").click(function(){
loadPopup();
("#countryselection").val([$(this).attr("countries")]); //Notice the this.attr
});

I hope you can see what I am trying to do here. Somehow I need the Jquery to take in the “countries” attribute as an array, although I am not sure how to do this.

Thanks for the 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-02T16:45:00+00:00Added an answer on June 2, 2026 at 4:45 pm

    http://jsfiddle.net/V62Yq/

    <a href="#" id="openpop" countries="US,CA">link</a>
    
    <select id="countryselection" multiple="multiple">
        <option>US</option>
        <option>CA</option>
        <option>GB</option>
    </select>
    ​
    
    //The event handler
    $("#openpop").click(function(e){
        e.preventDefault();
        var vals = $(this).attr('countries').split(",");
        $("#countryselection").val(vals); 
    });​
    

    And though adding a country attribute is kind of valid depending on the html spec you are targeting, you should likely use data attributes for information such as “countries” in your link tag. You can access them the same way.

    $(selector).attr('data-countries');
    
    <a href="#" id="openpop" data-countries="US,CA">link</a>
    

    See: http://ejohn.org/blog/html-5-data-attributes/

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

Sidebar

Related Questions

I have one method that opens a file and passes off to another function
I have a button that opens a panel in a popup window and then
I have an app that opens a non-modal form from the main form. The
I am asking this question that how can you develop such thing with PHP+MySQL+jQuery
I have a bookmarklet that when clicked opens up a div popup on their
I have a JQuery modal popup form on a classic ASP page. It's set
I have written a little JQuery / Javascript add on for our form, that
I have a form that uses jQuery Validate. You click the Submit button, form
I have a simple form like below that I have added the jQuery validations
I have a very simple message to display in one jQuery popup and I

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.