Solved

SharePoint - Select List

Posted on 2013-01-15
2
413 Views
Last Modified: 2013-03-04
I have used the following JavaScript to set the default item in a "List form Field"   The script is working and the correct item in the combo box is selected  but the event has not fired to reload the list box. below.  If I select an item manually (i,e. with a mouse) it works fine.  What have I missed.

var elm = document.getElementById("idAttachmentsTable");
          if (elm == null || elm.rows.length == 0)
          document.getElementById("idAttachmentsRow").style.display='none';
         
         
         
  _spBodyOnLoadFunctionNames.push("fillDefaultValues");



function fillDefaultValues()
{
var opt=document.getElementById("ctl00_m_g_f12af616_6ab4_4c5c_a59b_146a2e9b17ae_ff61_ctl00_ctl00_SelectGroup");

var opts = opt.options;
var l = opts.length;
opts.selectedIndex = 4;

      
      }


Sharepoint
0
Comment
Question by:Kevin Robinson
2 Comments
 
LVL 20

Expert Comment

by:informaniac
ID: 38779072
The question is not very clear. Can you please explain a bit more. Is this the entire code?

Also please use the code block to write the code. That shows us a bit of clear code.
0
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 500 total points
ID: 38779141
Hi,
as long as I do not have all the HTML code, its a little bit of blind coding - but the following should work.
<script type="text/javascript" src="http://dev.dse.local/sites/ee/SiteAssets/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
function SetPreselect() {
var optionToSelectText = "YOURTEXTOFTHEOPTIONTOBESELECTED";
jQuery("#idAttachmentsRow").hide();
jQuery("#ctl00_m_g_f12af616_6ab4_4c5c_a59b_146a2e9b17ae_ff61_ctl00_ctl00_SelectGroup").val(optionToSelectText);
}
_spBodyOnLoadFunctionNames.push("SetPreselect");
</script>

Open in new window


Please adjust the text of the variable optionToSelectText to fit the option text of your choice e.g. "Sh Sq Rooms".

HTH
Rainer
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Note:  There are two main ways to deploy InfoPath forms:  Server-side and directly through the SharePoint site.  Deploying a server-side InfoPath form means the form is approved by the Administrator, thus allowing greater functionality in the form. …
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now