Hi Guys,
feeling gr8 to get introduced to this forum. I had a problem toggling with two fields. I am using "
toggle" function in jquery. In this i am able to hide one field , but at the same time i need to display another field. when clicked on that field, again it should hide and another field should be displayed.
we can do it if we have static field id . But here i am dynamically creating tags and displaying on page using
document.createElement("a"); LIKE THIS.
Here in this context i need to get the next field present to this ,
in order to toggle between these two fields.
My Question here is : HOW CAN I GET THE NEXT FIELD PRESENT TO THIS FIELD,
TOTOGGLE BETWEEN THESE TWO. I am posting my code here. Please have a look.
Waiting for reply.
<apex:page standardController="Account">
<script type="text/javascript">
var __sfdcSessionId = '{!GETSESSIONID()}';
</script> <script src="../../soap/ajax/19.0/connection.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
window.onload = setupPage;
function setupPage() {
var state = {
output : document.getElementById("output"),
startTime : new Date().getTime()};
var callback = { onSuccess: layoutResults,
onFailure: queryFailed,
source: state};
sforce.connection.query( "Select Notes__c From Notes_and_Emails__c", callback);
}
function queryFailed(error, source) {
source.output.innerHTML = "An error has occurred: " + error;
}
function layoutResults(queryResult, source) {
try{
if (queryResult.size > 0) {
var output ;
var records = queryResult.getArray('records');
for (var i = 0; i < records.length; i++)
{
var notes = records[i]; output = notes.Notes__c;
var substr = notes.Notes__c.substring(0,3);
var btag=document.createElement("h2");
var divtag = document.createElement("h3");
var atag = document.createElement("a");
var atag1 = document.createElement("a");
var trimdivtag = document.createElement("b");
divtag.setAttribute("id","divid");
trimdivtag.setAttribute("id", "trimdivid");
divtag.setAttribute("style","display:none");
atag1.setAttribute("style","display:none");
var btag_content = document.createTextNode("Subject");
var div_content = document.createTextNode(output);
var a_content = document.createTextNode("ReadMore....");
var a_content1 = document.createTextNode("Collapse");
var trimdiv_content = document.createTextNode(notes.Notes__c.substring(0,25)+ "......");
btag.appendChild(btag_content);
divtag.appendChild(div_content);
atag.appendChild(a_content); atag1.appendChild(a_content1);
trimdivtag.appendChild(trimdiv_content);
var sp2 = document.getElementById("output");
var parentDiv = sp2.parentNode; parentDiv.insertBefore(btag, sp2);
parentDiv.insertBefore(divtag, sp2);
parentDiv.insertBefore(trimdivtag, sp2);}
}
}catch(error){
alert(error);
}
$("b").click(function () {
$(this).toggle("fast");
$(this).find('#trimdivid').show();// i need to get this element accessible to toggle....
}); }
</script>
<div style="height:150px;overflow-x: hidden;overflow-y: scroll;border-style:solid" id="maindiv">
<div id="output"></div>
</div>
</apex:page>
Thanks,
Krishna.