Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Adding Javascript to List Form Fields in SPD

  Asked By: Judith    Date: Feb 08    Category: Sharepoint    Views: 7258

How can I add Javascript to List Form Field in SharePoint Designer?

Share: 

 

5 Answers Found

 
Answer #1    Answered By: Winston Ayers     Answered On: Feb 08

What do you want it to do?????????????

 
Answer #2    Answered By: Moshe Harding     Answered On: Feb 08

I am trying to do some javascript  validation in my Custom List Edit form. I
have a List form  field of Choice type. I want to associate this field  with
some custom javascript function. This javascript function will toggle the
visibility of another List Form field of Person or Group type and clear its
value, based on the Choice field selection.

 
Answer #3    Answered By: Carly Meyer     Answered On: Feb 08

Add a Content Editor Web Part to your list  for and put your JS in the Source
Editor of that web part. To get the Edit Page option on List forms you have to
add:

?pageview=shared&toolpaneview=2

to the end of the ...Form.aspx in the URL. Example:

ServerName/.../NewForm.aspx?pageview=shared&too\
lpaneview=2

 
Answer #4    Answered By: Dewayne Clay     Answered On: Feb 08

The question is not of using a CEWP or not. The question is how to associate
javascript  function to a List form  Field. Please post a sample for my
scenario. For your information, I am posting my scenario again.

I am trying to do some javascript validation in my Custom List Edit form. I
have a List Form field  of Choice type. I want to associate this field with
some custom javascript function. This javascript function will toggle the
visibility of another List Form field of Person or Group type and clear its
value, based on the Choice field selection.

 
Answer #5    Answered By: Angelina Newman     Answered On: Feb 08

<script type="text/javascript"
src="ajax.googleapis.com/.../jquery.min.js"></script>
<script type="text/javascript">

//This function will fire after all of the
//page document elements have loaded:
$(document).ready(function() {

//I actually have three rows in my form  with Unit Change in
//the column name. (Unit Change Planned Date, Unit Change
//Effective Date, and Unit Change Comments)
//A form's column names are in <nobr> tags.
//nobrUnit is a jQuery collection of <nobr> elements:
var nobrUnit = $("nobr:contains('Unit Change')");

//I am actually appending the asterisk(*) that you
//see when a field  is required to each of the column names.
//I am making it red with the ms-formvalidation class. This doesn't make
//the field required but does offer emphasis. I
//actually am capturing this validation in my workflow...
//ugly I know!
var vSpan = "<span class=ms-formvalidation> *</span>";
$(nobrUnit).append(vSpan);

//Find the closest <tr> tag going up the DOM tree.
//This is the row you will show/hide.
//trUnit is a jQuery collection of those three rows:
var trUnit = $(nobrUnit).closest("tr");

//initially hide the three rows:
$(trUnit).hide();

//Find the checkbox that will trigger the show/hide.
//The only way I could traverse to that <input> tag
//was to find a parent element (<span> tag) to get a
//child reference with. The <span> tag's title element
//is also the text of that checkbox:
var inputUnit = $("span[title=Unit Test]>input");

//capture click behavior of the checkbox (<input> tag):
$(inputUnit).click(function(){

// If Unit Test checked:
if ($(inputUnit).is(":checked"))
{

//show the hidden <tr>s:
$(trUnit).show();

} //end if

else
{
//otherwise, hide it:
$(trUnit).hide();

//and set Unit Change Comment (multi-line textbox) value to no text:
$("*[title*=Unit Change]").val("");
} //end else

}); //end $(inputUnit).click function

}); //end $(document).ready function

</script>

 
Didn't find what you were looking for? Find more on Adding Javascript to List Form Fields in SPD Or get search suggestion and latest updates.




Tagged: