Isaac
asked on
selected value
HI,
I get a syntax error on the following that is in a javascript file. Whatever is selected from the drop-down, I want it to stay selected. The value selected does appear in the querstring(ex: Module.aspx?FY=2017).
I get a syntax error on the following that is in a javascript file. Whatever is selected from the drop-down, I want it to stay selected. The value selected does appear in the querstring(ex: Module.aspx?FY=2017).
"<tr><td class='bold'>Select Fiscal Year</td><td><select id='fyTarget' onchange='redirect()'><option value=''></option><option value='2017'"+getQueryString("FY")==2017 ? 'Selected' : ' ';+">2017</option><option value='2018'>2018</option><option value='2019'>2019</option><option value='2020'>2020</option><option value='2021'>2021</option></select></td></tr>"+
Whatever is selected from the drop-down, I want it to stay selectedalternatively, try change your dropdown to asp.net DropDownList control
like:
<asp:DropDownList ID="fyTarget" AutoPostBack="true" runat="server">
<asp:ListItem Value="">Select an item</asp:ListItem>
<asp:ListItem Value="2017">2017</asp:ListItem>
<asp:ListItem Value="2018">2018</asp:ListItem>
<asp:ListItem Value="2019">2019</asp:ListItem>
<asp:ListItem Value="2020">2020</asp:ListItem>
<asp:ListItem Value="2021">2021</asp:ListItem>
</asp:DropDownList>
Code behind:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
String varFY = Request.QueryString["FY"] == null ? "" : Request.QueryString["FY"].ToString();
if (fyTarget.Items.FindByValue(varFY) != null)
{
fyTarget.Items.FindByValue(varFY).Selected = true;
}
}
//other stuffs
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
None of the suggestions/solutions worked. Here is more code for a bigger picture.
jQuery(document).ready(function () {
SP.SOD.executeOrDelayUntilScriptLoaded(retrieveListItems, "sp.js");
vaFY = getQueryString("FY");
$("#fyTarget").val(vaFY);
});
/*-----------------------------------------------------------------------------------------------------*/
//HTML Layout for datatable (Need to make this generate dynamic eventually.)
/*-----------------------------------------------------------------------------------------------------*/
var htmlTbl = "<table border='0' cellspacing='5' cellpadding='5'>"+
"<tbody>"+
"<tr><td class='bold'>Project Cost Minimum:</td><td><input type='text' id='min' name='min'></td></tr>"+
"<tr><td class='bold'>Project Cost Maximum:</td><td><input type='text' id='max' name='max'></td></tr>"+
"<tr><td class='bold'>Select Fiscal Year</td><td><select id='fyTarget' onchange='redirect()'><option value=''></option><option value='2017'>2017</option><option value='2018'>2018</option><option value='2019'>2019</option><option value='2020'>2020</option><option value='2021'>2021</option></select></td></tr>"+
"</table>"+
"<table id='prioritize' class='display' cellspacing='0' width='100%'>"+
"<thead>"+
"<th>ID</th>"+
"<th>Project Title</th>"+
"<th>Total</th>"+
"<th>Building Priority</th>"+
"<th>State Priority</th>"+
"<th>National Priority</th>"+
"<th>Project Number</th>"+
"<th>State</th>"+
"<th>Station</th>"+
"<th>Total Project Cost</th>"+
"<th>Planned Design Fiscal Year</th>"+
"<th>Planned Construction Fiscal Year</th>"+
"<th>Higher Approval</th>"+
"</thead>"+
"<tbody>";
/*-------------------------------------------------------------------------------------------------------*/
//Redirect function based on fiscal year filter drop-down selection
/*-------------------------------------------------------------------------------------------------------*/
function redirect() {
var selectID = document.getElementById("fyTarget");
var selectVal = selectID.options[selectID.selectedIndex].value;
//var path = _spPageContextInfo.webServerRelativeUrl+"/SitePages/priorityModule.aspx?FY="+selectVal;
var path = "http://iwebarea.com/SitePages/priorityModuleVA.aspx?FY="+selectVal;
//alert(_spPageContextInfo.webServerRelativeUrl);
window.location = path;
}
/*-------------------------------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------------------------------*/
//Grabs values from querystring
/*-------------------------------------------------------------------------------------------------------*/
function getQueryString(name, url) {
if (!url) {
url = window.location.href;
}
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
/*var getQueryString = function (field, url) {
var href = url ? url : window.location.href;
var reg = new RegExp('[?&]' + field + '=([^&#]*)', 'i');
var string = reg.exec(href);
return string ? string[1] : null;
}; */
/*-------------------------------------------------------------------------------------------------------*/
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It's for creating a datatable. The code is too long so here's an excerpt
/*-------------------------------------------------------------------------------------------------------*/
//Success on data retrieval from 'retrieveListItems()'. Transforms HTML table to datatable and creates
//range functionality.
/*-------------------------------------------------------------------------------------------------------*/
function onQuerySucceeded(sender, args) {
var listItemInfo = '';
var listItemEnumerator = collListItem.getEnumerator();
var i = 0;
while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
projItem = {};
projItem.ID = oListItem.get_item('ID');
projItem.facilityNumber = oListItem.get_item('Faciltity_x0020_Priority');
htmlTbl += "<tr class='Drm_pj_align'><td>" + oListItem.get_item('ID') + "</td>" +
"<td>" + checkForNull(oListItem.get_item('Title')) + "</td>"+
"<td>" + checkForNull(oListItem.get_item('pri_x0020_Total')) + "</td>"+
"<td data-order="+oListItem.get_item('Faciltity_x0020_Priority')+"> "+
"<input type='text' size='1' disabled name = 'rowID-" + oListItem.get_item('ID') + "' id='facilityRowID-" + oListItem.get_item('ID') + "' data-curVal=" + oListItem.get_item('Faciltity_x0020_Priority') + " value=" + checkForNull(oListItem.get_item('Faciltity_x0020_Priority')) + ">"+
"</td>" +
"<td data-order="+oListItem.get_item('Priority')+"> "+
"<input type='text' size='2' disabled name = 'rowID-" + oListItem.get_item('ID') + "' id='RowID-" + oListItem.get_item('ID') + "' data-curVal=" + oListItem.get_item('Priority') + " value=" + checkForNull(oListItem.get_item('Priority')) + ">"+
"</td>" +
"<td data-order="+oListItem.get_item('National_x0020_Priority')+"> "+
"<input type='text' size='2' disabled name = 'rowID-" + oListItem.get_item('ID') + "' id='nationalRowID-" + oListItem.get_item('ID') + "' data-curVal=" + oListItem.get_item('National_x0020_Priority') + " value=" + checkForNull(oListItem.get_item('National_x0020_Priority')) + ">"+
"</td>" +
"<td>" + checkForNull(oListItem.get_item('Project_x0020_Number')) + "</td>"+
"<td>" + checkForNull(oListItem.get_item('Sate')) + "</td>" +
"<td>" + checkForNull(oListItem.get_item('Station')) + "</td>" +
"<td>" + checkForNull(oListItem.get_item('Total_x0020_Project_x0020_Cost')) + "</td>"+
"<td>" + constructionDesign(oListItem.get_item('Design_x0020_Obligation_x0020_Da'),oListItem.get_item('AServices'),"AServices") +"</td>"+
"<td>" + constructionDesign(oListItem.get_item('Construction_x0020_Obligation_x0'),oListItem.get_item('Construction_x0020_Cost'),"Budget") +"</td>"+
"<td><select id='HigherApproval'><option></option><option value='"+checkForNull(oListItem.get_item('HigherApproval'))+"'>"+checkForNull(oListItem.get_item('HigherApproval'))+"</option></select></td></tr>";
items.push([oListItem.get_item('ID'), oListItem.get_item('Faciltity_x0020_Priority')]);
itemsID.push(oListItem.get_item('Faciltity_x0020_Priority'));
}
htmlTbl += "</tbody></table>";
$("#divListItems").html(htmlTbl);
ASKER
Once the page redirects and refreshes, there where the problem seems to happen.
Okay, well the actual variable you're referencing "fyTarget" isn't in the snippet you provided.
It's really tough to pinpoint the error without seeing the actual parts.
My "guess" would be that on your $("#divListItems").html call, you should be setting the selected .val() right after that.
But still pretty sure the code generating fyTarget has a couple of type mismatches in it as per the first post.
It's really tough to pinpoint the error without seeing the actual parts.
My "guess" would be that on your $("#divListItems").html call, you should be setting the selected .val() right after that.
But still pretty sure the code generating fyTarget has a couple of type mismatches in it as per the first post.
ASKER
OK. Here's all the code
jQuery(document).ready(function () {
SP.SOD.executeOrDelayUntilScriptLoaded(retrieveListItems, "sp.js");
vaFY = getQueryString("FY");
jQuery("#fyTarget").val(vaFY);
});
/*-----------------------------------------------------------------------------------------------------*/
//HTML Layout for datatable (Need to make this generate dynamic eventually.)
/*-----------------------------------------------------------------------------------------------------*/
var htmlTbl = "<table border='0' cellspacing='5' cellpadding='5'>"+
"<tbody>"+
"<tr><td class='bold'>Project Cost Minimum:</td><td><input type='text' id='min' name='min'></td></tr>"+
"<tr><td class='bold'>Project Cost Maximum:</td><td><input type='text' id='max' name='max'></td></tr>"+
"<tr><td class='bold'>Select Fiscal Year</td><td><select id='fyTarget' onchange='redirect()'><option value=''></option value=''><option value='2017'>2017</option><option value='2018'>2018</option><option value='2019'>2019</option><option value='2020'>2020</option><option value='2021'>2021</option></select></td></tr>"+
"</table>"+
"<table id='prioritize' class='display' cellspacing='0' width='100%'>"+
"<thead>"+
"<th>ID</th>"+
"<th>Project Title</th>"+
"<th>Important Total</th>"+
"<th>Facility Priority</th>"+
"<th>State Priority</th>"+
"<th>National Priority</th>"+
"<th>Project Number</th>"+
"<th>State</th>"+
"<th>Station</th>"+
"<th>Total Project Cost</th>"+
"<th>Planned Design Fiscal Year</th>"+
"<th>Planned Construction Fiscal Year</th>"+
"<th>Higher Approval</th>"+
"</thead>"+
"<tbody>";
/*-------------------------------------------------------------------------------------------------------*/
//Redirect function based on fiscal year filter drop-down selection
/*-------------------------------------------------------------------------------------------------------*/
function redirect() {
var selectID = document.getElementById("fyTarget");
var selectVal = selectID.options[selectID.selectedIndex].value;
//var path = _spPageContextInfo.webServerRelativeUrl+"/SitePages/priorityModuleVA.aspx?FY="+selectVal;
var path = "http://iwebarea.com/SitePages/priorityModuleVA.aspx?FY="+selectVal;
//alert(_spPageContextInfo.webServerRelativeUrl);
window.location = path;
}
/*-------------------------------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------------------------------*/
//Retrieves all list items and filters based on fiscal year drop-down selection
/*-------------------------------------------------------------------------------------------------------*/
function retrieveListItems() {
var clientContext = new SP.ClientContext();
var oList = clientContext.get_web().get_lists().getByTitle('Project_Module');
var camlQuery = new SP.CamlQuery();
if (!vaFY){
var prjQry = "<View><Query><OrderBy><FieldRef Name='Important_x0020_Total' Ascending='True' /></OrderBy></Query></View>";
//alert(prjQry);
}else {
var prjQry = "<View>"+
"<Query>"+
"<Where>"+
"<And>"+
"<Gt>"+
"<FieldRef Name='Total_x0020_Project_x0020_Cost' />"+
"<Value Type='Currency'>25000</Value>"+
"</Gt>"+
"<Or>"+
"<Eq>"+
"<FieldRef Name='Design_x0020_Obligation_x0020_Da' />"+
"<Value Type='Text'>"+vaFY+"</Value>"+
"</Eq>"+
"<Eq>"+
"<FieldRef Name='Construction_x0020_Obligation_x0' />"+
"<Value Type='Text'>"+vaFY+"</Value>"+
"</Eq>"+
"</Or>"+
"</And>"+
"</Where>"+
"</Query>"+
"</View>";
//alert(prjQry);
}
camlQuery.set_viewXml(prjQry);
this.collListItem = oList.getItems(camlQuery);
clientContext.load(collListItem);
clientContext.executeQueryAsync(
Function.createDelegate(this, this.onQuerySucceeded),
Function.createDelegate(this, this.onQueryFailed)
);
}
/*-------------------------------------------------------------------------------------------------------*/
/*Array will contain two values, item id and new priority value. Global so it can be used in multiple functions.*/
var items = [];
var itemsID = [];
var projItemArray = new Array();
var i = 0;
/*-------------------------------------------------------------------------------------------------------*/
//Success on data retrieval from 'retrieveListItems()'. Transforms HTML table to datatable and creates
//range functionality.
/*-------------------------------------------------------------------------------------------------------*/
function onQuerySucceeded(sender, args) {
var listItemInfo = '';
var listItemEnumerator = collListItem.getEnumerator();
//Will be used to build object array of ID and priorityNumber
//var projItemArray = new Array();
var i = 0;
while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
projItem = {};
projItem.ID = oListItem.get_item('ID');
projItem.facilityNumber = oListItem.get_item('Faciltity_x0020_Priority');
htmlTbl += "<tr class='DRM_pj_align'><td>" + oListItem.get_item('ID') + "</td>" +
"<td>" + checkForNull(oListItem.get_item('Title')) + "</td>"+
"<td>" + checkForNull(oListItem.get_item('Important_x0020_Total')) + "</td>"+
"<td data-order="+oListItem.get_item('Faciltity_x0020_Priority')+"> "+
"<input type='text' size='1' disabled name = 'rowID-" + oListItem.get_item('ID') + "' id='facilityRowID-" + oListItem.get_item('ID') + "' data-curVal=" + oListItem.get_item('Faciltity_x0020_Priority') + " value=" + checkForNull(oListItem.get_item('Faciltity_x0020_Priority')) + ">"+
"</td>" +
"<td data-order="+oListItem.get_item('State_x0020_Priority')+"> "+
"<input type='text' size='2' disabled name = 'rowID-" + oListItem.get_item('ID') + "' id='StateRowID-" + oListItem.get_item('ID') + "' data-curVal=" + oListItem.get_item('State_x0020_Priority') + " value=" + checkForNull(oListItem.get_item('State_x0020_Priority')) + ">"+
"</td>" +
"<td data-order="+oListItem.get_item('National_x0020_Priority')+"> "+
"<input type='text' size='2' disabled name = 'rowID-" + oListItem.get_item('ID') + "' id='nationalRowID-" + oListItem.get_item('ID') + "' data-curVal=" + oListItem.get_item('National_x0020_Priority') + " value=" + checkForNull(oListItem.get_item('National_x0020_Priority')) + ">"+
"</td>" +
"<td>" + checkForNull(oListItem.get_item('Project_x0020_Number')) + "</td>"+
"<td>" + checkForNull(oListItem.get_item('State')) + "</td>" +
"<td>" + checkForNull(oListItem.get_item('Station')) + "</td>" +
"<td>" + checkForNull(oListItem.get_item('Total_x0020_Project_x0020_Cost')) + "</td>"+
"<td>" + constructionDesign(oListItem.get_item('Design_x0020_Obligation_x0020_Da'),oListItem.get_item('AEServices'),"AEServices") +"</td>"+
"<td>" + constructionDesign(oListItem.get_item('Construction_x0020_Obligation_x0'),oListItem.get_item('Construction_x0020_Cost'),"Budget") +"</td>"+
"<td><select id='HigherApproval'><option value=''></option><option value='"+checkForNull(oListItem.get_item('HigherApproval'))+"'>"+checkForNull(oListItem.get_item('HigherApproval'))+"</option></select></td></tr>";
items.push([oListItem.get_item('ID'), oListItem.get_item('Faciltity_x0020_Priority')]);
itemsID.push(oListItem.get_item('Faciltity_x0020_Priority'));
}
htmlTbl += "</tbody></table>";
$("#divListItems").html(htmlTbl);
/*Apply DataTable style */
var table = $('#prioritize').DataTable();
// Event listener to the two range filtering inputs to redraw on input
$('#min, #max').keyup( function() {
table.draw();
} );
$('table#prioritize').on('focus','input[type=text]',function(){
//Grab the value before it is repleaced
oldvalue = $(this).val();
//Find array index of the oldvalue
curValIndx= itemsID.indexOf(parseInt(oldvalue));
}).on('change','input[type=text]',function(){
//Value being replaced
var curVal = $(this).attr('data-curVal');
//New Value
var newVal = $(this).val();
//Unique id of List Item. Format: 'rowID-xx'
var itemID = $(this).attr('id');
var id=getId(itemID);
/*Update and Prioritize*/
prioritize(newVal, id, curVal, curValIndx);
});
determineGroup();
}
/*-------------------------------------------------------------------------------------------------------*/
//Determines if user belongs in State, National or Facility group and disables/enables appropriate
//priority boxes.
/*-------------------------------------------------------------------------------------------------------*/
function determineGroup() {
$().SPServices({
operation: "GetGroupCollectionFromUser",
userLoginName: $().SPServices.SPGetCurrentUser(),
async: false,
completefunc: function (xData, Status) {
if($(xData.responseXML).find("Group[Name='State']").length==1) {
$('input[id*="StateRowID"]').removeAttr('disabled');
}else if($(xData.responseXML).find("Group[Name='National']").length==1){
$('input[id*="nationalRowID"]').removeAttr('disabled');
}else {
$('input[id*="facilityRowID"]').removeAttr('disabled');
}
}
});
}
/*-------------------------------------------------------------------------------------------------------*/
$.fn.dataTable.ext.search.push(
function( settings, data, dataIndex ) {
var min = parseInt( $('#min').val(), 10 );
var max = parseInt( $('#max').val(), 10 );
var totProjCost = parseFloat( data[8] ) || 0; // use data for the age column
if ( ( isNaN( min ) && isNaN( max ) ) ||
( isNaN( min ) && totProjCost <= max ) ||
( min <= totProjCost && isNaN( max ) ) ||
( min <= totProjCost && totProjCost <= max ) )
{
return true;
}
return false;
}
);
/*-------------------------------------------------------------------------------------------------------*/
//Checks for nulls
/*-------------------------------------------------------------------------------------------------------*/
function checkForNull(val) {
if (val === null) {
return " ";
}else {return val;}
}
/*-------------------------------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------------------------------*/
//Determine current VA fiscal year
/*-------------------------------------------------------------------------------------------------------*/
function VAFiscalY(d)
{
var VA_FY;
if (d.getMonth() > 8)
{ VA_FY = d.getFullYear() + 1;} else { VA_FY = d.getFullYear();}
return VA_FY;
}
/*-------------------------------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------------------------------*/
//Deals with null values and adds A/E services and Construction Budget values to the corresponding
//table cells
/*-------------------------------------------------------------------------------------------------------*/
function constructionDesign(plannedCategoryVal,categoryAmount,planCategory)
{
var now = new Date();
var CurentVAFiscalYear = VAFiscalY(now);
if (planCategory == "AEServices"){
var AESdisplayVal = checkForNull(categoryAmount) == " " ? " " : "$"+categoryAmount.toLocaleString();
return (checkForNull(plannedCategoryVal) !=" " && CurentVAFiscalYear == plannedCategoryVal) ? plannedCategoryVal+"</br><span style='text-decoration:underline'>A/E Services:</span><span style='background-color:#7CFC00'>"+AESdisplayVal+"</span>": 'n/a';
}
else {
var constructionBudgetDisplayVal = checkForNull(categoryAmount) == " " ? " " : "$"+categoryAmount.toLocaleString();
return (checkForNull(plannedCategoryVal) !=" " && CurentVAFiscalYear == plannedCategoryVal) ? plannedCategoryVal+"</br><span style='text-decoration:underline'oListItem.get_item('Construction_x0020_Cost')>Construction Budget:</span><span style='background-color:#7CFC00'>"+constructionBudgetDisplayVal+"</span>": 'n/a';
} }
/*-------------------------------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------------------------------*/
//Grabs values from querystring
/*-------------------------------------------------------------------------------------------------------*/
/*function getQueryString(name, url) {
if (!url) {
url = window.location.href;
}
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}*/
var getQueryString = function (field, url) {
var href = url ? url : window.location.href;
var reg = new RegExp('[?&]' + field + '=([^&#]*)', 'i');
var string = reg.exec(href);
return string ? string[1] : null;
};
/*-------------------------------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------------------------------*/
//Function name: getId
//Description: Grab the id from the id name that is passed to it. Format: 'rowID-xx'
/*-------------------------------------------------------------------------------------------------------*/
function getId(iID) {
var myID = iID.split("-");
var ID = myID[1];
return ID;
}
/*-------------------------------------------------------------------------------------------------------*/
//Function name: getId
//Description: Uses JSOM to Update 'Priority Number' column with new priority value.
// Item ID and priority number passed in
/*-------------------------------------------------------------------------------------------------------*/
function update(pVal, itID){
var rowID = parseInt(itID);
var ptVal = parseInt(pVal);
var ctx = new SP.ClientContext.get_current();
var customList = ctx.get_web().get_lists().getByTitle('Project_Module');
var listItem = customList.getItemById(rowID);
/*Set the value and update*/
listItem.set_item('Faciltity_x0020_Priority', ptVal);
listItem.update();
ctx.executeQueryAsync(
function(){
/*Need to change this to show on the page*/
//alert('Priority updated');
},
function(sender, args){ alert('Error: ' + args.get_message()); });
}
function onQueryFailed(sender, args) {
alert('Request failed. '+args.get_message() + '\n' + args.get_stackTrace());
}
/*-------------------------------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------------------------------*/
//Function name: prioritize
//Description: Uses JSOM to Update and shift 'Priority Number' up or down
// new value, id, old value, and array index of old value passed in
/*-------------------------------------------------------------------------------------------------------*/
function prioritize(newValue, uid, oldValue, oldValIndx) {
//Update change first
update(newValue, uid);
if (newValue < oldValue) {
var subNewVal = oldValue - newValue;
var n=0;
var projIdx = oldValIndx-1;
while (n<subNewVal) {
var pNum = projItemArray[projIdx].priorityNumber+1;
var pID = projItemArray[projIdx].ID;
update(pNum,pID);
projIdx = projIdx-1
n++;
}
} else if (newValue > oldValue) {
var subNewVal = newValue - oldValue;
var q=0;
var projIdx = oldValIndx+1;
while (q<subNewVal) {
var pNum = projItemArray[projIdx].priorityNumber-1;
var pID = projItemArray[projIdx].ID;
update(pNum,pID);
projIdx = projIdx+1
q++;
}
}
}
/*-------------------------------------------------------------------------------------------------------*/
Okay, thnx. My guess, is the initial call with the "executeOrDelayUntilScript Loaded" means the actual table creating / insertion is happening after your call to get the querystring and set the value.
Your "jQuery("#fyTarget").val(v aFY);" call is being made before the table is inserted into the dom.
Move those two lines into the onQuerySucceeded function where you insert:
Your "jQuery("#fyTarget").val(v
Move those two lines into the onQuerySucceeded function where you insert:
jQuery(document).ready(function () {
SP.SOD.executeOrDelayUntilScriptLoaded(retrieveListItems, "sp.js");
// REMOVE from here
//vaFY = getQueryString("FY");
//jQuery("#fyTarget").val(vaFY);
});
htmlTbl += "</tbody></table>";
$("#divListItems").html(htmlTbl);
// INSERT here, after the table and dropdown have been put into the DOM
vaFY = getQueryString("FY");
jQuery("#fyTarget").val(vaFY);
Okay, my fault I didn't check where else you were using that. Your call to get the qs value isn't dependent on any other scripts, you can move that to the top, but I'd leave it outside the (ready):
jQuery(document).ready(function () {
SP.SOD.executeOrDelayUntilScriptLoaded(retrieveListItems, "sp.js");
// REMOVE from here
//jQuery("#fyTarget").val(vaFY);
});
vaFY = getQueryString("FY");
htmlTbl += "</tbody></table>";
$("#divListItems").html(htmlTbl);
// INSERT here, after the table and dropdown have been put into the DOM
jQuery("#fyTarget").val(vaFY);
ASKER
This is really strange.
I added this back and it started working.
I added this back and it started working.
jQuery(document).ready(function () {
SP.SOD.executeOrDelayUntilScriptLoaded(retrieveListItems, "sp.js");
vaFY = getQueryString("FY");
jQuery("#fyTarget").val(vaFY);
});
ASKER
Thanks guys for all your help
You are welcome.
Change this part:
Open in new window
to:
Open in new window