Solved

jquery text boxes not rendering

Posted on 2013-05-14
4
232 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
  • 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
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)

747 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

12 Experts available now in Live!

Get 1:1 Help Now