sullisnyc44
asked on
jquery & CEWP to hide fields. why isn't this code working?
I'm attempting to use jquery to hide fields on a new form.
I'm trying to modify the Help Desk template from the fab 40. I thought I was applying code that I have used successfully in the past (with the help of experts in this forum :D)
but it's not working. The field is called ComplianceReview and it is a Yes/No checkbox. I do not want it to show up on new forms.
Attached is my code. And some html about the field.
I'm trying to modify the Help Desk template from the fab 40. I thought I was applying code that I have used successfully in the past (with the help of experts in this forum :D)
but it's not working. The field is called ComplianceReview and it is a Yes/No checkbox. I do not want it to show up on new forms.
Attached is my code. And some html about the field.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
//hide all of the check-boxes I don’t need
$("a[name$='ComplianceReview']").closest("tr").hide();
});
</script>
<TD nowrap="true" valign="top" width="190px" class="ms-formlabel"><H3 class="ms-standardheader">
<nobr>Compliance Review</nobr>
</H3></TD>
<TD valign="top" class="ms-formbody" width="400px">
<!-- FieldName="Compliance Review"
FieldInternalName="ComplianceReview"
FieldType="SPFieldBoolean"
-->
<span dir="none">
<input id="ctl00_m_g_2a0e593d_0e76_40eb_919b_29c48acea959_ctl00_ctl04_ctl05_ctl00_ctl00_ctl04_ctl00_ctl00_BooleanField" type="checkbox" name="ctl00$m$g_2a0e593d_0e76_40eb_919b_29c48acea959$ctl00$ctl04$ctl05$ctl00$ctl00$ctl04$ctl00$ctl00$BooleanField" /><br>
</span>
</TD>
ASKER
I use this code with no issues on another page (see snippet)
A solution I got from here:
http://www.endusersharepoint.com/2009/07/06/jquery-to-the-rescue-automate-all-day-event/
Where do I have too many "$"?
A solution I got from here:
http://www.endusersharepoint.com/2009/07/06/jquery-to-the-rescue-automate-all-day-event/
Where do I have too many "$"?
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$('td.ms-dttimeinput').hide(); //hides the times on Start Time
$('span[title=All Day Event] > input').attr("checked","checked"); // checks All Day Event
//hide all of the check-boxes I don’t need
$('tr:has(span[title=Recurrence])').not('tr:has(tr)').hide();
$('tr:has(span[title=All Day Event])').not('tr:has(tr)').hide();
$('tr:has(span[title=Workspace])').not('tr:has(tr)').hide();
});
</script>
$("a[name$='ComplianceRevi ew']").clo sest("tr") .hide();
});
you have an extra $ after the word name.
});
you have an extra $ after the word name.
ASKER
hmmmm... does like this either
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
//hide all of the check-boxes I don’t need
$("a[name='ComplianceReview']").closest("tr").hide();
});
</script>
When you view source of the rendered HTML does the field name match correctly? Same capitalization and everything? Could you post the rendered HTML source?
sorry, must obviously I think you need this...
$("input[name='ComplianceR eview']"). closest("t r").hide() ;
You are not applying this to an "a" element, you are binding it to an input.
$("input[name='ComplianceR
You are not applying this to an "a" element, you are binding it to an input.
ASKER
I posted the html for the field in my first post. do you need more than that?
I believe all the capitalization, etc is the way it should be.
this isn't working either (see snippet)
I believe all the capitalization, etc is the way it should be.
this isn't working either (see snippet)
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
//hide all of the check-boxes I don’t need
$("input[name='Compliance Review']").closest("tr").hide();
});
</script>
Sorry, what I was getting at is that this is the input field in your code...
<input id="ctl00_m_g_2a0e593d_0e7 6_40eb_919 b_29c48ace a959_ctl00 _ctl04_ctl 05_ctl00_c tl00_ctl04 _ctl00_ctl 00_Boolean Field" type="checkbox" name="ctl00$m$g_2a0e593d_0 e76_40eb_9 19b_29c48a cea959$ctl 00$ctl04$c tl05$ctl00 $ctl00$ctl 04$ctl00$c tl00$Boole anField" /><br>
I am assuming that when you call this page from a browser the field does not look like that, rather it gets generated with the actual name="ComplianceReview"
Your example shows the name as Compliance Review, your jQuery calls is ComplianceReview (no space)...those would be two different fields. I was asking to see the source HTML so I could verify what the fieldname actually was.
<input id="ctl00_m_g_2a0e593d_0e7
I am assuming that when you call this page from a browser the field does not look like that, rather it gets generated with the actual name="ComplianceReview"
Your example shows the name as Compliance Review, your jQuery calls is ComplianceReview (no space)...those would be two different fields. I was asking to see the source HTML so I could verify what the fieldname actually was.
ASKER
I was attempting both ways. the 'display name' and the internal name.
That was in the code I posted? So sorry. attached is the complete view source of the newform page.
viewsourceNewForm.htm
That was in the code I posted? So sorry. attached is the complete view source of the newform page.
viewsourceNewForm.htm
ASKER
ahhh I see what you are saying...
how do I fix that?
how do I fix that?
hmmm. I thought the program was rending the field into the friendly name. I just added this and the row went away...(don't look very pretty)
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></s cript>
<script type="text/javascript">
$(function(){
//hide all of the check-boxes I don't need
$("input[name='ctl00$m$g_2 a0e593d_0e 76_40eb_91 9b_29c48ac ea959$ctl0 0$ctl04$ct l05$ctl00$ ctl00$ctl0 4$ctl00$ct l00$Boolea nField']") .closest(" tr").hide( );
});
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></s
<script type="text/javascript">
$(function(){
//hide all of the check-boxes I don't need
$("input[name='ctl00$m$g_2
});
</script>
ASKER
lol. works for me too. :((
ok - how do I fix that?
Why the heck did that happen to the id?
Can I set it to hide all checkboxes?
like something $('tr:has(td[id=SPFieldCal culated])' ).not('tr: has(tr)'). hide();
but boolean?
ok - how do I fix that?
Why the heck did that happen to the id?
Can I set it to hide all checkboxes?
like something $('tr:has(td[id=SPFieldCal
but boolean?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks so much - that was the 'easy' way around it since there are no other checkboxes on the form.
but what happened with my field name?
but what happened with my field name?
You have an extra $ sign in there. Also, IE does not like hiding table rows. You may want to put <tbody></tbody> around that row and change the jquery to closest('tbody')