After:
Prompted by an email request from Peter (a reader and someone who helped me test formWorks code), I worked up this bit of JavaScript that, when inserted into a SharePoint form, will let you modify the width of the form itself and the width of the labels and content as well.
<script type="text/javascript">
function fillWidth() {
var formWidth = "100%"; // set this to whatever size you want the form to be on the page
var labelWidth = "200px"; // set this to the width you want the form label to be
var contentWidth = "100%";
var inputWidth = "100%";
// this will resize the form width
document.getElementById("onetIDListForm").style.width = formWidth;
// this block resizes the elements on the form
var styles = new Array();
styles = (document.styleSheets[0].cssRules) ? document.styleSheets[0].cssRules : document.styleSheets[0].rules;
for (var i in styles) {
if (styles[i].selectorText == ".ms-formlabel") {
styles[i].style.width = labelWidth; // this will resize the labels on the left of the form
} else if (styles[i].selectorText == ".ms-formbody") {
styles[i].style.width = contentWidth; // this will resize the content portion of the form
} else if (styles[i].selectorText == ".ms-long" || styles[i].selectorText == ".ms-rtelong") {
styles[i].style.width = inputWidth; // this will resize the input objects
}
}
}
// run the size changers when the page is loaded
document.body.onLoad = fillWidth();
</script>


0 comments:
Post a Comment