Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Javascript to access choice form fields

  Asked By: Bridget    Date: Dec 17    Category: Sharepoint    Views: 5173

I need some help in trying to access the values of form fields on a NewForm.aspx page. The goal is to have one field (Title) automatically updated based on the values that are entered in another text field (JobID) and the value that is selected from a Choice field drop down list (Designer). The title will need to be changed when either of those fields is changed. Specifically, where I need help is in dealing with the drop down lists.

Question 1) How do I add an OnChange event for the drop-down list?

Question 2) How do I programmatically access the text (and/or value) of the selected item in the drop-down list?

What I’ve done is added a CEWP web part to the NewForm.aspx page that has JavaScript to handle all of this.

I’ve added an OnChange event for my text field without a problem, which calls when a change is made to the JobID field. I’ve done that as follows:

<script language=javascript for="urn:schemas-microsoft-com:office:office#JobID" event="onchange">



And I can get the value of the JobID without a problem. I’ve done that as follows:

function getJobID() {

var elems = document.getElementsByTagName("INPUT");

for (var i=0;i<elems.length;i++) {

if(elems[i].title=='Job ID') {

return elems[i].value;



return "";


Does anyone have any suggestions on how I can get the value of and respond to changes to a drop-down list? I spent hours on this yesterday and would appreciate any help anyone can offer.



2 Answers Found

Answer #1    Answered By: Tejaswani Barve     Answered On: Dec 17

You can always rewrite the ListFormWebPart … More on that idea is in my article at http://www.devx.com/webdev/Article/30026

Answer #2    Answered By: SURYAKUMAR PULIPATI     Answered On: Jul 26
Didn't find what you were looking for? Find more on Javascript to access choice form fields Or get search suggestion and latest updates.