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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:50:45+00:00 2026-05-27T09:50:45+00:00

I am trying to build a table (using sql) based on the selections selected

  • 0

I am trying to build a table (using sql) based on the selections selected in a few multiple select boxes. Here is my javascript/jquery code:

function make_table(whichButton)
 {
            console.log("Whichbotton = " + whichButton);
            //var prog = $("#program option:selected").val().join(" ");
            var prog = $("#program").val() || [];
            console.log("prog first= " + prog);
            prog = prog.join(" ");
            console.log("prog second= " + prog);
            var sch = $("#school").val() || [];
            sch = sch.join(" ");
            var trm = $("#term").val() || [];
            trm = trm.join(" ");
            var ext = $("#extension").val() || [];
            ext = ext.join(" ");

My understanding is that val() gets an array of all the selections, and the join function returns a string separating the values with the separator. But something isn’t right. The console.log says that the variable prog doesn’t have a value (or it just blank) even after I did the join. What is wrong?

Also, I coded each variable as being equal to ).val() || [];… I did this because thats how the example on the jquery site did it. But what does it mean? The jquery specifications say that if the array is empty then it reurns null as the default value, what does || [] mean?

  • 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-27T09:50:45+00:00Added an answer on May 27, 2026 at 9:50 am

    || [] means that if the val returns null, then to instead choose an empty array to be the element.

    it means the same as:

    if ($("#term").val() == null){
        trm = []
    }
    else{
       trm = $("#term").val();
    }
    

    as for your problem, you need to make sure your val() are returning correctly. try logging $(“#term”).val() and see if its returning what you expect it to return. if it is, you know you are doing something wrong elsewhere, though I don’t see anything offhand

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

Sidebar

Related Questions

I'm trying to build a navigation system using categories table with hierarchies. Normally, the
Im trying to build call to action button on my site using jQuery. I
I am trying to build a SQL query using ActiveRecord methods. The query has
I am using sql server 2008 and I'm trying to build a query for
Hello i'm trying to build a table cell using div tag and while doing
I am trying to build an Oracle stored procedure which will accept a table
I am trying to build a dependency graph of tables based on the foreign
Trying to build sslsniff on a RHEL 5.2 system here. When compiling sslsniff on
I'm trying to build a criteria object using NHibernate that will compare date1 to
I have been trying to build an SQL query to return matches between three

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.