Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

SharePoint - Select List

Posted on 2013-01-15
2
453 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

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. …
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

807 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