Solved

set default value in multivalue combo

Posted on 2013-02-06
10
466 Views
Last Modified: 2013-02-13
Hi,

I want to display multicolumn combo box in the html file for which i am using jquery.multicolselect.js.

The problem i am facing is i want to set the default value (can be any of the given below) to be displayed in the mulitcombo.

Thanks in advance.

Source code of the jsp file is given below


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript"
      src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript"
      src="${pageContext.request.contextPath}/resources/js/multiselectcombo/jquery.multicolselect.js"></script>
</script>
</head>
<script language="javascript" type="text/javascript">
      jQuery(document)
                  .ready(
                              function() {
                                    $("#datatable")
                                                .multicolselect(
                                                            {
                                                                  buttonImage : "${pageContext.request.contextPath}/resources/images/selectbutton.gif",
                                                                  valueCol : 1,
                                                                  hideCol : 0
                                                            });

                              });
</script>
<body>
      <form>
            <div>
                  <!-- Controlling the multicombo value  scroll,height,width -->
                  <div id="datatable"
                        style="overflow-y: auto; overflow-x: auto; height: 80px; width: 850px">

                        <%%>
                        <table border="1" cellspacing="0" width="100%">
                              <tr>
                                    <td>1</td>
                                    <td>1</td>
                                    <td>A1</td>
                              </tr>
                              <tr>
                                    <td>2</td>
                                    <td>2</td>
                                    <td>A2</td>
                              </tr>
                              <tr>
                                    <td>3</td>
                                    <td>3</td>
                                    <td>A3</td>
                              </tr>

                        </table>

                  </div>

            </div>


      </form>
</body>
</html>
jquery.multicolselect.js
0
Comment
Question by:Rocking
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 38862837
Do you have a link to the documentation of that select?
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 38862844
your not even mention that select box in your html code
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 38862891
It's a widget
0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

Author Comment

by:Rocking
ID: 38863759
Do you have a link to the documentation of that select?

http://code.google.com/p/jquerymulticolumnselectbox/
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 38863966
Use : $("#datatable").find("tr:eq(1)").click();
Or : $("#datatable").find("tr:contains('A1')").click(); // not good if you've more than one row with A1
Or : $("#datatable").find("tr").filter(function() { $(this).find("td:eq(2)") == "A1" }).click(); // good if you've more than one row with A1, we use the third (index 2) cell

Test page : http://jsfiddle.net/WLqDC/2/
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 38864068
Post a request here
http://multicolselect.blogspot.nl/
and the author might just create a command for it
0
 

Author Comment

by:Rocking
ID: 38868732
@leakim971

I tried with the below code but not able to set the default value in the multi select combo box

 $("#datatable").find("tr:eq(1)").click();

By default i want the first record to be displayed in the multi combo box?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 38868752
post a link to your page.
It work fine in the jsfiddle
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 38869215
remove the space between e and q


$("#datatable").find("tr:eq(1)").click();

Open in new window

0
 

Author Comment

by:Rocking
ID: 38872569
It's (Default value is set)  working now.

There is one problem that if we click on the browser or any other text box on the html page  the div (datatable) remains open.It closes only when clicked in the table.


Since i am making mulitselect combo,if u can provide some help on the above also as how to close if user click on anywhere on the screen i.e functionality like a select box in html
Thanks
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
document.write() deleting all existing HTML 5 49
Jquery-Javascript setAttribute function help 7 18
jQuery Scroll To Top 5 38
Binding a Grid in Javascript 5 42
This article discusses how to create an extensible mechanism for linked drop downs.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question