Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SharePoint - Select List

Posted on 2013-01-15
2
Medium Priority
?
494 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
[X]
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
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 2000 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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…

618 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