Solved

SharePoint - Select List

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

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
SharePoint Designer 2010 has tools and commands to do everything that can be done with web parts in the browser, and then some – except uploading a web part straight into a page that is edited in SPD. So, can it be done? Scenario For a recent pr…
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…

816 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

11 Experts available now in Live!

Get 1:1 Help Now