Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

dropdown change event and drop down value in SharePoint 2013 using javascript

$
0
0

Hi,

I need to fire event on dropdown change and get the change value in sharepoint 2013 list form using CEWP.  in 2010 i was using below function

getField('select','Project Status').onchange = function() {getvalue()};

function getField(fieldType,fieldTitle)
{
var docTags = document.getElementsByTagName(fieldType);
for (var i=0; i < docTags.length; i++)
{
if (docTags[i].title == fieldTitle)
{
return docTags[i]
}
}
}

Problem in 2013: HTML source is differernt than 2010, so there is no docTags[i].title to find using above function.

<tr>
  <td nowrap="true" valign="top" width="113px" class="ms-formlabel"><h3 class="ms-standardheader">
  <nobr>Project Status<span class="ms-accentText" title="This is a required field." > *</span></nobr>
 </h3></td>
  <td valign="top" width="350px" class="ms-formbody">
  <!-- FieldName="Project Status"
    FieldInternalName="ProjectStatus"
    FieldType="SPFieldChoice"
    -->
   <span id='WPQ2ce7df540-6389-434e-ac5f-0751121b3870ProjectStatus' data-sp-control='SPFieldChoice' data-sp-options='{&quot;mode&quot;:2,&quot;source&quot;:&quot;ProjectStatus&quot;}'></span>  
  </td>
 </tr>

Please suggest how to implement in 2013 with javacript only(cannot use jquery)

Thanks


Viewing all articles
Browse latest Browse all 7589

Trending Articles