SPServices.SPArrangeChoices not working for me :(

Mar 8, 2011 at 4:32 PM

I REALLY want this to work for me, but I'm assuming I'm doing something (stupid) wrong. I'm uisng jquery-1.4.4.min.js with jquery.SPServices-0.5.8.min.js in a custom NewForm.aspx file. I've added the <xsl:comment> as described just above my <SharePoint:FormField> tag and still nothing. No errors, but no horizontal radio buttons either. I'm stumped. I've tried 3 other jquery versions as well, but no go. Any help would be greatly appreciated.

Mar 8, 2011 at 6:08 PM

I have the exact same issue, no errors and no horizontal radio buttons or checkboxes. I tried both List Form and Custom List Form.  For the Custom List Form, I added the <xsl:comment>FieldName="Housing"</xsl:comment> just above the <SharePoint:FormField> tag.

 

<asp:Content id="Content2" runat="server" contentplaceholderid="PlaceHolderMain">
<script language="javascript" type="text/javascript" src="../Javascript/jquery-1.4.4.min.js"></script>
<script language="javascript" type="text/javascript" src="../Javascript/jquery.SPServices-0.5.8.min.js"></script>
<script language="javascript" type="text/javascript">
 $().SPServices.SPArrangeChoices({
    columnName: "Housing",
    perRow: 2
});
</script>

 

Please advise. Thanks

Mar 8, 2011 at 8:16 PM

I had to wrap the code in a $(document).ready(function(). This seems to work for now. Thanks

<asp:Content id="Content2" runat="server" contentplaceholderid="PlaceHolderMain">
<script language="javascript" type="text/javascript" src="../Javascript/jquery-1.4.4.min.js"></script>
<script language="javascript" type="text/javascript" src="../Javascript/jquery.SPServices-0.5.8.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
 $().SPServices.SPArrangeChoices({
    columnName: "Housing",
    perRow: 2
   });
});
</script>

Mar 9, 2011 at 12:00 AM

Hi tllocke,

Following orlena's steps sounds like a solid approach.  I would try to get your script to work on the OOTB form.  That would rule out whether or not your script needs to be tweaked.  Feel free to post the code as well.  Maybe we can spot something that's missing.  I get stuck on a semicolon or a comma all the time.

Mar 9, 2011 at 4:12 PM

Beauty!  It must have been something else on my page that was causing it to NOT work.  I threw my hands in the air and started from scratch and voila!  It works perfectly.  Love it!  Thanks all for your quick responses.  LOVE this library!  Great work!

Coordinator
Mar 9, 2011 at 4:15 PM

Glad you both got it working. The $(document).ready is not always necessary, but basically what it says is "Wait for the page to fully load, and then run this script". I like to use it for all of my script which runs on page load, if only to clearly set it off from the script which runs upon some user action or event.

M.

Mar 9, 2011 at 4:23 PM

Just a quick note:  I figured out what I did wrong to make this not work.  When I change this line: <td width="400px" valign="top" class="ms-formbody">to this: <td width="400px" valign="top" class="ms-formlabel"> ('cause I don't want a different color behind the TD), it doesnt' work.  Oddness.  Even if I simply take out the class itself entirely... it doesn't work.  Anyone else have this?

Coordinator
Mar 9, 2011 at 4:31 PM

I look for that class in my selector to get at the right column in the DOM. If you want to override the default color, you can add a different class in addition to that one and all should be good.

M.