Solved

jquery text boxes not rendering

Posted on 2013-05-14
4
241 Views
Last Modified: 2013-05-21
Please help!

I'm not sure why my text boxes are not showing.  4 input boxes are supposed to appear where you see the red marks below:
input not showing
Here's my code

function GetCurrentResult(xData, status) 
	{
		var currentYear = (new Date).getFullYear();

		//alert(xData.responseXML.<wbr ></wbr>xml);
		//Iterates through each row and returns information - Populates the "Performer" dropdown with values from the Objectives list
		var buildHtml = "<Table><tr><td>Initiative<wbr ></wbr>(number here)</td><td> and (statement)</td></tr>";				
		var LastTwocurrentYear = 13;
		$(xData.responseXML).find(<wbr ></wbr>"z\\:row")<wbr ></wbr>.each(func<wbr ></wbr>tion() 
		{  
			//This decides how many input boxes to provide
			var ReportingFrequency = $(this).attr("ows_Reportin<wbr ></wbr>gFrequency<wbr ></wbr>")

			$("#initiative").append("<<wbr ></wbr>tr><td>(in<wbr ></wbr>itiative measure)</td><td> and statement</td></tr><tr><td<wbr ></wbr>>Frequency<wbr ></wbr> of Calculation:</td><td></td><wbr ></wbr></tr><tr><<wbr ></wbr>td colspan='2'>Please provide 'Current Result' for each quarter of each Fiscal Year.</td></tr>");
			if (ReportingFrequency=="Quar<wbr ></wbr>terly")
			{
				var qtrInput = 4;
				$("#initiative").append("<<wbr ></wbr>tr><td colspan='2'>FY"+currentYea<wbr ></wbr>r);
	
				for(var i = 0; i < qtrInput; i++)
				{
		
					//$("#initiative").append(<wbr ></wbr>"Qtr "+i": <input id='CurrentResultFY"+LastT<wbr ></wbr>wocurrentY<wbr ></wbr>ear+" type='text' style='width:150px;' /></td></tr>");
					$("#initiative").append("Q<wbr ></wbr>tr 1 <input type='text' style='width:150px' />");
					LastTwocurrentYear++;	
					
				}
				$("#initiative").append("<<wbr ></wbr>/td></tr>"<wbr ></wbr>);
			}
		
		});
	}

Open in new window

0
Comment
Question by:Isaac
[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
  • 3
4 Comments
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 39167347
Hi,
your code looks a little scrambled, can you try this:
function GetCurrentResult(xData, status) {
	var currentYear = (new Date).getFullYear();
	//alert(xData.responseXML.<wbr ></wbr>xml);
	//Iterates through each row and returns information - Populates the "Performer" dropdown with values from the Objectives list
	var buildHtml = "<table><tr><td>Initiative (number here)</td><td> and (statement)</td></tr>";				
	var LastTwocurrentYear = 13;
	$(xData.responseXML).find("z\\:row").each(function() {  
		//This decides how many input boxes to provide
		var ReportingFrequency = $(this).attr("ows_ReportingFrequency");
		$("#initiative").append("<tr><td>(initiative measure)</td><td> and statement</td></tr><tr><td>Frequency of Calculation:</td><td></td></tr><tr><td colspan='2'>Please provide 'Current Result' for each quarter of each Fiscal Year.</td></tr>");
		if (ReportingFrequency=="Quarterly")
		{
			var qtrInput = 4;
			$("#initiative").append("<tr><td colspan='2'>FY"+currentYear);
			for(var i = 0; i < qtrInput; i++)
			{
				//$("#initiative").append(<wbr ></wbr>"Qtr "+i": <input id='CurrentResultFY"+LastT<wbr ></wbr>wocurrentY<wbr ></wbr>ear+" type='text' style='width:150px;' /></td></tr>");
				$("#initiative").append("Qtr 1 <input type='text' style='width:150px' />");
				LastTwocurrentYear++;
			}
			$("#initiative").append("</td></tr>");
		}
	});
}

Open in new window


Can you perhaps attach the xData.responseXml to be able to test the generated output?

The variable buildHtml is not used at all.
It would also be nice to have the surrounding HTML e.g. the initial content of #initiative.

HTH
Rainer
0
 
LVL 5

Author Comment

by:Isaac
ID: 39169485
Hi Rainer,

I still don't get anything with the modified code you provided.

Also, I could not append the xData to a div, so I provided an image below.
<table id="initiative" border="1" width="65%">
<tr>
	<td></td>
</tr>
</table>

<Div id="xData"></div>
<script type="text/javascript" src="../js/jquery-1.8.2.min.js" language="javascript"></script>
<script type="text/javascript" src="../js/jquery.SPServices-0.7.2.min.js" language="javascript"></script>
<script type="text/javascript" src="../js/jquery-ui-LatestVersion.js" language="javascript"></script>

<script type="text/javascript">
$(document).ready(function() {
currSiteUrl = $().SPServices.SPGetCurrentSite();
 
var soapEnv3 =
        "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>" +
            "<soapenv:Body>" +
                "<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>" +
                    "<listName>Objective Level Performance Measures</listName>" +
					"<query><Query><Where><Eq><FieldRef Name='Title' /><Value Type='Text'>1.1.1M</Value></Eq></Where></Query></query>" +
                    "<viewFields>" +
                        "<ViewFields>" +
                        "</ViewFields>" +
                    "</viewFields>" +
                "</GetListItems>" +
            "</soapenv:Body>" +
        "</soapenv:Envelope>";
        $.ajax(
	{
	    url: currSiteUrl + "/_vti_bin/lists.asmx",
	    async: true,
	    type: "POST",
	    dataType: "xml",
	    data: soapEnv3,
	    complete: GetCurrentResult,
	    contentType: "text/xml; charset=\"utf-8\""
	});	
});


	function GetCurrentResult(xData, status) {
	var currentYear = (new Date).getFullYear();
	alert(xData.responseXML.xml);
	$("#xData").append(xData);
	//Iterates through each row and returns information - Populates the "Performer" dropdown with values from the Objectives list
	var buildHtml = "<table><tr><td>Initiative (number here)</td><td> and (statement)</td></tr>";				
	var LastTwocurrentYear = 13;
	$(xData.responseXML).find("z\\:row").each(function() {  
		//This decides how many input boxes to provide
		var ReportingFrequency = $(this).attr("ows_ReportingFrequency");
		$("#initiative").append("<tr><td>(initiative measure)</td><td> and statement</td></tr><tr><td>Frequency of Calculation:</td><td></td></tr><tr><td colspan='2'>Please provide 'Current Result' for each quarter of each Fiscal Year.</td></tr>");
		if (ReportingFrequency=="Quarterly")
		{
			var qtrInput = 4;
			$("#initiative").append("<tr><td colspan='2'>FY"+currentYear);
			for(var i = 0; i < qtrInput; i++)
			{			
				$("#initiative").append("Qtr 1 <input type='text' style='width:150px' />");
				LastTwocurrentYear++;
			}
			$("#initiative").append("</td></tr>");
		}
	});
	}
</script>

Open in new window


xData Data:

xData
0
 
LVL 5

Accepted Solution

by:
Isaac earned 0 total points
ID: 39171097
function GetCurrentResult(xData, status) {
	var currentYear = (new Date).getFullYear();
	alert(xData.responseXML.xml);
	$("#xData").append(xData);
	//Iterates through each row and returns information - Populates the "Performer" dropdown with values from the Objectives list

	$(xData.responseXML).find("z\\:row").each(function() {  
		//This decides how many input boxes to provide
		var ReportingFrequency = $(this).attr("ows_ReportingFrequency");
		$("#initiative").append("<tr><td>(initiative measure)</td><td> and statement</td></tr><tr><td>Frequency of Calculation:</td><td></td></tr><tr><td colspan='2'>Please provide 'Current Result' for each quarter of each Fiscal Year.</td></tr>");
		if (ReportingFrequency=="Quarterly")
		{
			var qtrInput = 4;
			var nextYear = currentYear+1;
			currentResultYear(qtrInput,currentYear);
			currentResultYear(qtrInput,nextYear);
		}
	});
	}
	
	function currentResultYear(qtrInput,Year)
	{
			var j=1;
			
			for(var i = 0; i < qtrInput; i++)
			{							
				$("#initiative").append("<tr><td colspan='2'>FY"+Year+" Qtr"+j+"<input type='text' value='' name='CurrentResultFY13' /></td></tr>");
				//CurrentResultFY13Qtr1
				j++;
			}
	}

Open in new window

0
 
LVL 5

Author Closing Comment

by:Isaac
ID: 39183768
Issue resolved
0

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

707 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