Inserting a date when radio button is checked
-
Hello I hope someone can help me with the following problem. I have a form in sharepoint that has a number of items in it that includes checkboxes, drop down lists and text fields etc. One of these fields called Status has three radio buttons in it labelled New, In progress and Closed. The field below this is called Date Closed and has a text field next to it using a Date and Time control type (this gives a small calender button next to the text field where people can click to choose the date). I would like to know whether it is possible to enter the current date into the text field when the "Closed" radio button is clicked. In other words, it automatically populates the date in the text field when the user clicks the Closed radio button. I suppose removing the date if the user changes back to the "In progress" field would be useful too. I have tried editing the page in question using sharepoint designer and am able to inject the code I was trying to use to do this into the EditForm.aspx page (the page is a form in a sharepoint list). The code does appear in the page when loaded in the web browser but it doesn't seem to run correctly. Unfortunately I don't have enough knowledge of Javascript to work out why it won't execute correctly. The code is basically an edit of http://blogs.msdn.com/b/sharepointdesigner/archive/2007/06/13/using-javascript-to-manipulate-a-list-form-field.aspx I've copied the HTML the site generates for the radio buttons below hoping this will help with the naming of the fields:
<span class="ms-RadioText" title="New"><input id="ctl00_m_g_9bfbce10_a236_4f06_b0fb_d8e53e39be05_ctl00_ctl04_ctl26_ctl00_ctl00_ctl04_ctl00_ctl00" type="radio" name="ctl00$m$g_9bfbce10_a236_4f06_b0fb_d8e53e39be05$ctl00$ctl04$ctl26$ctl00$ctl00$ctl04$ctl00$RadioButtons" value="ctl00" /><label for="ctl00_m_g_9bfbce10_a236_4f06_b0fb_d8e53e39be05_ctl00_ctl04_ctl26_ctl00_ctl00_ctl04_ctl00_ctl00">New</label></span></td>
</tr><tr>
<td><span class="ms-RadioText" title="In progress"><input id="ctl00_m_g_9bfbce10_a236_4f06_b0fb_d8e53e39be05_ctl00_ctl04_ctl26_ctl00_ctl00_ctl04_ctl00_ctl01" type="radio" name="ctl00$m$g_9bfbce10_a236_4f06_b0fb_d8e53e39be05$ctl00$ctl04$ctl26$ctl00$ctl00$ctl04$ctl00$RadioButtons" value="ctl01" checked="checked" /><label for="ctl00_m_g_9bfbce10_a236_4f06_b0fb_d8e53e39be05_ctl00_ctl04_ctl26_ctl00_ctl00_ctl04_ctl00_ctl01">In progress</label></span></td>
</tr><tr>
<td>< -
Hello I hope someone can help me with the following problem. I have a form in sharepoint that has a number of items in it that includes checkboxes, drop down lists and text fields etc. One of these fields called Status has three radio buttons in it labelled New, In progress and Closed. The field below this is called Date Closed and has a text field next to it using a Date and Time control type (this gives a small calender button next to the text field where people can click to choose the date). I would like to know whether it is possible to enter the current date into the text field when the "Closed" radio button is clicked. In other words, it automatically populates the date in the text field when the user clicks the Closed radio button. I suppose removing the date if the user changes back to the "In progress" field would be useful too. I have tried editing the page in question using sharepoint designer and am able to inject the code I was trying to use to do this into the EditForm.aspx page (the page is a form in a sharepoint list). The code does appear in the page when loaded in the web browser but it doesn't seem to run correctly. Unfortunately I don't have enough knowledge of Javascript to work out why it won't execute correctly. The code is basically an edit of http://blogs.msdn.com/b/sharepointdesigner/archive/2007/06/13/using-javascript-to-manipulate-a-list-form-field.aspx I've copied the HTML the site generates for the radio buttons below hoping this will help with the naming of the fields:
<span class="ms-RadioText" title="New"><input id="ctl00_m_g_9bfbce10_a236_4f06_b0fb_d8e53e39be05_ctl00_ctl04_ctl26_ctl00_ctl00_ctl04_ctl00_ctl00" type="radio" name="ctl00$m$g_9bfbce10_a236_4f06_b0fb_d8e53e39be05$ctl00$ctl04$ctl26$ctl00$ctl00$ctl04$ctl00$RadioButtons" value="ctl00" /><label for="ctl00_m_g_9bfbce10_a236_4f06_b0fb_d8e53e39be05_ctl00_ctl04_ctl26_ctl00_ctl00_ctl04_ctl00_ctl00">New</label></span></td>
</tr><tr>
<td><span class="ms-RadioText" title="In progress"><input id="ctl00_m_g_9bfbce10_a236_4f06_b0fb_d8e53e39be05_ctl00_ctl04_ctl26_ctl00_ctl00_ctl04_ctl00_ctl01" type="radio" name="ctl00$m$g_9bfbce10_a236_4f06_b0fb_d8e53e39be05$ctl00$ctl04$ctl26$ctl00$ctl00$ctl04$ctl00$RadioButtons" value="ctl01" checked="checked" /><label for="ctl00_m_g_9bfbce10_a236_4f06_b0fb_d8e53e39be05_ctl00_ctl04_ctl26_ctl00_ctl00_ctl04_ctl00_ctl01">In progress</label></span></td>
</tr><tr>
<td><What does your JavaScript look like? Have you tried debugging it?
I know the language. I've read a book. - _Madmatt
-
What does your JavaScript look like? Have you tried debugging it?
I know the language. I've read a book. - _Madmatt
Hi Mark Thanks for replying. The code is basically an edit of what one of the sharepoint developers posted on the MSDN blog here: http://blogs.msdn.com/b/sharepointdesigner/archive/2007/06/13/using-javascript-to-manipulate-a-list-form-field.aspx That code doesn't target radio buttons/text fields specifically which is what I'm after though I'm not sure what exactly I would need to change in it to make it so when a specific radio button is clicked it changes another field to be todays date. I can make the code in the link above execute on specific pages such as new forms or when editing current forms but I don't have enough knowledge of javascript to know how to target the specific radio button and text field present in the form. I'm pretty sure I need to modify the code to somehow reference the "closed" button using the id, name and input type tags in the HTML though I'm not sure what I have to do in order to get the onClick event to appear for the radio button neither am I sure on the javascript needed to make all this happen :( Thank you The code from the MSDN blog is:
<script type="text/javascript">
// This javascript sets the default value of a lookup field identified // by <<FIELD DISPLAY NAME>> to the value stored in the querysting variable // identified by <<QUERYSTRING VARIABLE NAME>> // Customize this javascript by replacing <<FIELD DISPLAY NAME>> and // <<QUERYSTRING VARIABLE NAME>> with appropriate values. // Then just paste it into NewForm.aspx inside PlaceHolderMain \_spBodyOnLoadFunctionNames.push("fillDefaultValues"); function fillDefaultValues() { var qs = location.search.substring(1, location.search.length); var args = qs.split("&"); var vals = new Object(); for (var i=0; i < args.length; i++) { var nameVal = args\[i\].split("="); var temp = unescape(nameVal\[1\]).split('+'); nameVal\[1\] = temp.join(' '); vals\[nameVal\[0\]\] = nameVal\[1\]; } setLookupFromFieldName("<<FIELD DISPLAY NAME>>", vals\["<<QUERYSTRING VARIABLE NAME>>"\]); } function setLookupFromFieldName(fieldName, value) { if (value == undefined) return; var theSelect = getTagFromIdentifierAndTitle("select","Lookup",fieldName); // if theSelect is null, it means that the target l
-
Hi Mark Thanks for replying. The code is basically an edit of what one of the sharepoint developers posted on the MSDN blog here: http://blogs.msdn.com/b/sharepointdesigner/archive/2007/06/13/using-javascript-to-manipulate-a-list-form-field.aspx That code doesn't target radio buttons/text fields specifically which is what I'm after though I'm not sure what exactly I would need to change in it to make it so when a specific radio button is clicked it changes another field to be todays date. I can make the code in the link above execute on specific pages such as new forms or when editing current forms but I don't have enough knowledge of javascript to know how to target the specific radio button and text field present in the form. I'm pretty sure I need to modify the code to somehow reference the "closed" button using the id, name and input type tags in the HTML though I'm not sure what I have to do in order to get the onClick event to appear for the radio button neither am I sure on the javascript needed to make all this happen :( Thank you The code from the MSDN blog is:
<script type="text/javascript">
// This javascript sets the default value of a lookup field identified // by <<FIELD DISPLAY NAME>> to the value stored in the querysting variable // identified by <<QUERYSTRING VARIABLE NAME>> // Customize this javascript by replacing <<FIELD DISPLAY NAME>> and // <<QUERYSTRING VARIABLE NAME>> with appropriate values. // Then just paste it into NewForm.aspx inside PlaceHolderMain \_spBodyOnLoadFunctionNames.push("fillDefaultValues"); function fillDefaultValues() { var qs = location.search.substring(1, location.search.length); var args = qs.split("&"); var vals = new Object(); for (var i=0; i < args.length; i++) { var nameVal = args\[i\].split("="); var temp = unescape(nameVal\[1\]).split('+'); nameVal\[1\] = temp.join(' '); vals\[nameVal\[0\]\] = nameVal\[1\]; } setLookupFromFieldName("<<FIELD DISPLAY NAME>>", vals\["<<QUERYSTRING VARIABLE NAME>>"\]); } function setLookupFromFieldName(fieldName, value) { if (value == undefined) return; var theSelect = getTagFromIdentifierAndTitle("select","Lookup",fieldName); // if theSelect is null, it means that the target l
napy2 wrote:
The code is basically an edit of what one of the sharepoint developers posted on the MSDN blog
Yes, you said that already. BTW, it is customary when including a URL to provide a link.
napy2 wrote:
I don't have enough knowledge of javascript to know how
So what are you asking for then? How much help do you expect if you don't understand the code to do it? Modifying the default SharePoint code is NOT recommended as it used by all forms in the site. You may not want or need the code in all cases.
I know the language. I've read a book. - _Madmatt
-
napy2 wrote:
The code is basically an edit of what one of the sharepoint developers posted on the MSDN blog
Yes, you said that already. BTW, it is customary when including a URL to provide a link.
napy2 wrote:
I don't have enough knowledge of javascript to know how
So what are you asking for then? How much help do you expect if you don't understand the code to do it? Modifying the default SharePoint code is NOT recommended as it used by all forms in the site. You may not want or need the code in all cases.
I know the language. I've read a book. - _Madmatt
Mark Nischalke wrote:
So what are you asking for then? How much help do you expect if you don't understand the code to do it?
Well some help with the code would be great. I understand the basics of the javascript code posted in the blog but as to the statements needed to modify it sufficiently to make it do what I want it to do is another thing. I'm aware that modifying the default sharepoint code will modify all forms in the site (or more specifically all forms that use EditForms.aspx) and this is the behaviour I want. Thanks
-
Hello I hope someone can help me with the following problem. I have a form in sharepoint that has a number of items in it that includes checkboxes, drop down lists and text fields etc. One of these fields called Status has three radio buttons in it labelled New, In progress and Closed. The field below this is called Date Closed and has a text field next to it using a Date and Time control type (this gives a small calender button next to the text field where people can click to choose the date). I would like to know whether it is possible to enter the current date into the text field when the "Closed" radio button is clicked. In other words, it automatically populates the date in the text field when the user clicks the Closed radio button. I suppose removing the date if the user changes back to the "In progress" field would be useful too. I have tried editing the page in question using sharepoint designer and am able to inject the code I was trying to use to do this into the EditForm.aspx page (the page is a form in a sharepoint list). The code does appear in the page when loaded in the web browser but it doesn't seem to run correctly. Unfortunately I don't have enough knowledge of Javascript to work out why it won't execute correctly. The code is basically an edit of http://blogs.msdn.com/b/sharepointdesigner/archive/2007/06/13/using-javascript-to-manipulate-a-list-form-field.aspx I've copied the HTML the site generates for the radio buttons below hoping this will help with the naming of the fields:
<span class="ms-RadioText" title="New"><input id="ctl00_m_g_9bfbce10_a236_4f06_b0fb_d8e53e39be05_ctl00_ctl04_ctl26_ctl00_ctl00_ctl04_ctl00_ctl00" type="radio" name="ctl00$m$g_9bfbce10_a236_4f06_b0fb_d8e53e39be05$ctl00$ctl04$ctl26$ctl00$ctl00$ctl04$ctl00$RadioButtons" value="ctl00" /><label for="ctl00_m_g_9bfbce10_a236_4f06_b0fb_d8e53e39be05_ctl00_ctl04_ctl26_ctl00_ctl00_ctl04_ctl00_ctl00">New</label></span></td>
</tr><tr>
<td><span class="ms-RadioText" title="In progress"><input id="ctl00_m_g_9bfbce10_a236_4f06_b0fb_d8e53e39be05_ctl00_ctl04_ctl26_ctl00_ctl00_ctl04_ctl00_ctl01" type="radio" name="ctl00$m$g_9bfbce10_a236_4f06_b0fb_d8e53e39be05$ctl00$ctl04$ctl26$ctl00$ctl00$ctl04$ctl00$RadioButtons" value="ctl01" checked="checked" /><label for="ctl00_m_g_9bfbce10_a236_4f06_b0fb_d8e53e39be05_ctl00_ctl04_ctl26_ctl00_ctl00_ctl04_ctl00_ctl01">In progress</label></span></td>
</tr><tr>
<td><HI you can use visual webpart using visual studio to complete your task. you see siddiq-sharepoint2010.blogspot.com and see visual webpart video,Hope it helps you Thanks, MOHAMMAD SIDDIQALI.
-
HI you can use visual webpart using visual studio to complete your task. you see siddiq-sharepoint2010.blogspot.com and see visual webpart video,Hope it helps you Thanks, MOHAMMAD SIDDIQALI.