Set Date With Javascript
I have 2 date fields, A and B.
What I need to do is once I tab out of A, I need to set B to A+1year-1day.
I can do this in a page process on submit with
ADD_MONTHS(:P_A, 12)-1
but I need this to be done on change of field A.
Any help appreciated
Gus
Hi Gus,
you need to provide the date format you are using.
Add this to your FIELD A "html form element attributes":
onblur="javascript:fnc_field_b(this)"Add this to your page header:
<script>
function fnc_field_b(v_field_a){
/* Input: mm/dd/yyyy */
/* Output: dd.mm.yyyy */
/* Documentation: http://www.javascriptkata.com/2007/04/27/mastering-of-the-date-object-in-javascript/ */
/* http://programming.top54u.com/post/Javascript-Convert-String-to-Date.aspx */
/* Create date object */
var myDate = new Date(v_field_a.value);
/* Add 1 year */
myDate.setDate(myDate.getDate() + 365);
/* Create output string DD.MM.YYYY */
/* Day */
var myStr = (myDate.getDate() < 10 ? "0" + myDate.getDate().toString() : myDate.getDate().toString()) + ".";
/* Month */
myStr = myStr + (myDate.getMonth()+1 < 10 ? "0" + (myDate.getMonth()+1).toString() : (myDate.getMonth()+1).toString()) + ".";
/* Year */
myStr = myStr + myDate.getFullYear().toString();
/* Set value */
$s('P1_FIELD_B',myStr);
</script>Change the field P1_FIELD_B to the name of your field B name.
Best regards,
Tobias
Edited by: Tobias Arnhold on Mar 7, 2011 4:44 PM
Similar Messages
-
The question says it all:
What Are The Minimum Permissions In Order An User To Be Able To Access User Profile Data With JavaScript And REST API.?
In the User Profile -> Permissions there is only the option for "Full Control".Hi Nikolay,
Thanks for posting your issue, you need to set permissions on User Profiles = Read. Kindly find the below mentioned URLs to get the code and more details on this.
http://www.vrdmn.com/2013/02/sharepoint-2013-working-with-user.html
http://www.vrdmn.com/2013/07/sharepoint-2013-get-userprofile.html
http://sharepoint.stackexchange.com/questions/61714/sharepoint-2013-call-the-rest-api-from-sharepoint-hosted-app
http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2013/04/09/how-to-query-sharepoint-2013-using-rest-and-javascript.aspx
I hope this is helpful to you, mark it as Helpful.
If this works, Please mark it as Answered.
Regards,
Dharmendra Singh (MCPD-EA | MCTS)
Blog : http://sharepoint-community.net/profile/DharmendraSingh -
Formatting Date with JavaScript
Hello guys,
is there a way to change the date format with JavaScript? I have a library with different fields.
I hope you can help me!
Best regards
MatthiasYes
Check below
http://www.bentedder.com/convert-a-sharepoint-datetime-field-to-a-javascript-date-object/
function convertSPDate(d) {
* A function to convert a standard SharePoint
* date/time field (YYYY-MM-DD HH:MM:SS) to a
* javascript Date() object
* Author: Ben Tedder (www.bentedder.com)
// split apart the date and time
var xDate = d.split(" ")[0];
var xTime = d.split(" ")[1];
// split apart the hour, minute, & second
var xTimeParts = xTime.split(":");
var xHour = xTimeParts[0];
var xMin = xTimeParts[1];
var xSec = xTimeParts[2];
// split apart the year, month, & day
var xDateParts = xDate.split("-");
var xYear = xDateParts[0];
var xMonth = xDateParts[1];
var xDay = xDateParts[2];
var dDate = new Date(xYear, xMonth, xDay, xHour, xMin, xSec);
return dDate;
// create a couple of variables
var startTime;
var convertedStartTime;
// a standard SPServices call
$().SPServices({
operation: "GetListItems",
webURL: myListURL,
async:false,
listName: myListName,
CAMLRowLimit: 1,
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function(i){
// set the value of startTime to standard SP date/time field
startTime = $(this).attr("ows_startTime");
// set the convertedStartTime to a true javascript date
convertedStartTime = convertSPDate(startTime);
http://spservices.codeplex.com/wikipage?title=$%28%29.SPServices.SPConvertDateToISO
http://stackoverflow.com/questions/14283106/beginner-javascript-date-conversion-from-string-to-utc-date-js-into-sharepoint
http://stackoverflow.com/questions/14742625/how-to-convert-utc-date-by-javascript -
Formatting Dates with Javascript
Hi all. I'm tryign to find the solution on the web, but have
not had much
success yet.
I"m working on a customized button my my HTMLArea script that
puts a WYSIWYG
component on my form fields to insert the date.
My code is here:
editor.insertHTML((new Date()).toString());
Which outputs this:
Fri Nov 17 2006 10:08:35 GMT-0600 (Central Standard Time)
What I'm wanting to do is to output
Friday, November 17, 2006 with no timestamp, and no reports
of GMT/CST.
Any suggestions on where I can go to look? I've been at the
W3C, but I did
not see any way to format my string.
I've tried a lot of variations in trying to format the date
witha string,
but have not had any success.
This was my last script, which erred:
var d = new Date();
d.formatDate("D, M j");
d.toString();
editor.insertHTML(d);
TIA,
Jon Parkhurst
PriivaWeb
http://priiva.net.Thanks Mick, Reviewing now.
"Mick White" <[email protected]> wrote in
message
news:ejl3t8$sho$[email protected]..
> crash wrote:
>> Hi all. I'm tryign to find the solution on the web,
but have not had
>> much success yet.
>>
>> I"m working on a customized button my my HTMLArea
script that puts a
>> WYSIWYG component on my form fields to insert the
date.
>>
>> My code is here:
>> editor.insertHTML((new Date()).toString());
>>
>> Which outputs this:
>> Fri Nov 17 2006 10:08:35 GMT-0600 (Central Standard
Time)
>>
>> What I'm wanting to do is to output
>> Friday, November 17, 2006 with no timestamp, and no
reports of GMT/CST.
>
>
http://www.mickweb.com/javascript/dates/customDate.html
>
> editor.insertHTML(customDateString());
>
>
http://www.mickweb.com/javascript/dates/date.js
>
> function customDateString() {
> var now = new
Date(),H=now.getHours(),M=now.getMinutes();
> M=M<10?"0"+M:M;
> d =
>
["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]
> [now.getDay()]+", ";
> d+=
> ["January","February","March","April","May","June",
>
"July","August","September","October","November","December"]
> [now.getMonth()]+" ";
> d+=now.getDate()+" "+now.getFullYear();
> d+=", "+H%12+":"+M+["AM","PM"][Number(H>11)||H==0];
> return d
> }
>
> Mick
>
>>
>> Any suggestions on where I can go to look? I've been
at the W3C, but I
>> did not see any way to format my string.
>> I've tried a lot of variations in trying to format
the date witha
>> string, but have not had any success.
>> This was my last script, which erred:
>>
>> var d = new Date();
>> d.formatDate("D, M j");
>> d.toString();
>>
>> editor.insertHTML(d); -
Setting shadow with Javascript
For some odd reason, none of the Indesign's VBA-scripts works with InDesign CS5 anymore, maybe then reason is Office 2010 64-bit.
Anyway, Javascript works just fine, but I'm having difficulties to write following script with JavaScript. Can anybody help?
Simply script by setting up drop shadow for an active object.
Set myInDesign = CreateObject("InDesign.Application")
Set myObject = myInDesign.Selection.Item(1)
myObject.transparencySettings.dropShadowSettings.angle=135
myObject.transparencySettings.dropShadowSettings.opacity=33
myObject.transparencySettings.dropShadowSettings.distance=1
myObject.transparencySettings.dropShadowSettings.mode=2020623440
myObject.transparencySettings.dropShadowSettings.blendMode=1852797549Hey!
Here is the same code in JavaScript:
var myObject = app.selection[0];
with(myObject.transparencySettings.dropShadowSettings){
angle = 135;
opacity = 33;
distance = 1;
mode = ShadowMode.DROP;
blendMode = BlendMode.NORMAL;
Hope that helps.
tomaxxi
http://indisnip.wordpress.com/
http://inditip.wordpress.com/ -
Setting styles with javascript
getelementby('id').setAttribute lets you change a HTML objects attributes
However the style attirubute (getelementby('id').setAttribute("style","value goes here")); actually contatins many settings in what javacript sees as a single attribute.
as a result everytime i change a style setting with this i have to re-insert all of the other styles.
this is inconvinient at best.
and at worst means i have to store all of the set styles as javascript attributes and re-insert the whole lot.
is there another way of doing this
so that i can add or delete styles without the rest of the set styles being affected?function(){return A.apply(null,[this].concat($A(arguments)))}
I_Know_Nothing_at_all wrote:
I'm confused. Are you using the getElementby to write or set an individual style for multiple elements all over a page?
I use it to set a style for an element or elements where the style is dependant on some other factor, or has to be changed in responce to an event.
CSS alone cant do this because it does not have event listenters (except for psudo events such as :hover) cannot detect the styles and setting of anything (except for media rules) and does not have any sort of evaluative functions such as IFs, CASEs and basic arithmetic. -
Accessing Context Data with JavaScript in Adobe Form
Hi,
does anybody know, how to access a context element with javascript in an adobe form, because I have to decide which elements will be shown at the form, depending on one context value.
Thank you for your help!
Kind regards, Patrick.Hi,
First of all your WD context is mapped to the data view in the form. You can only access via scripting what is mapped to the data view and you get the values that the PDF currently has stored. The WD context and the data values in the context might differ (eg. due to editing).
Use scripting like xfa.resolveNode("xfa.dataset.data.<path.to.the.node>") to get a reference to the data node.
Then you can use the "value" property to access the data value.
Regards
Juergen Hauser -
Accessing Meta-Data with JavaScript
Hi,
In U3D one can add meta-information to the file.
Could anyone access this mata-information with JavaScript in Acrobat?
I could not find any documentation in the API or references on Internet, so far...
Thank you for every hint!
FelixFelix,<br /> Here's a hunk of code which will cycle through all the nodes, showing they're metadata. If the MD in the header is available, it will also be shown. Otherwise, no access to header info!<br /><br />//=========================================<br />console.println("scene.nodes.count = " + scene.nodes.count);<br />console.println ("----------------------------");<br />for (i=0; i<scene.nodes.count; i++)<br />{<br /> objNode = scene.nodes.getByIndex(i);<br /><br /> if (objNode == undefined)<br /> {<br /> console.println (" *** node = undefined ***\n\n");<br /> }<br /> else<br /> {<br /> console.println ("Node [" + i + "] metadataString = " + objNode.metadataString );<br /> }<br />}<br />//=========================================
-
Printing PDF attachments with Javascript?
I am very new to Javascript (and not a programmer) so please excuse my basic or un-correct terminology here! I've created an interactive pdf, and have set buttons (with javascript code) to print specific ranges of pages from the document. I've now been asked to have said buttons print attachments (which are also pdf's) in the same style... is this possible, and if so, does anyone have example code? The code that I used to print the page ranges, for example:
print ({nStart: 0, nEnd: 5});
Any assistance/guidance/help would be greatly appreciated!The document first has to be opened. You can do this via JavaScript with the doc.openDataObject method: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.509.html
This method returns a doc object, which you can use with the print method to print the document. You should then use the closeDoc method to close the document, as mentioned in and demonstrated in the documentation linked to above. -
My iPhone is set up with my old iCloud details - how do I change it to my new Apple ID - my email has changed. I can't remember old password and it's not recognising my date of birth. I no longer have the trusted device or key thing??
Try going to https://appleid.apple.com, click Manage my Apple ID and sign in with your current iCloud ID. Click edit next to the primary email account, change it back to your old email address and save the change. Then edit the name of the account to change it back to your old email address. You can now use your current password to turn off Find My iDevice, even though it prompts you for the password for your old account ID. Then save any photo stream photos that you wish to keep to your camera roll. When finished go to Settings>iCloud, tap Delete Account and choose Delete from My iDevice when prompted (your iCloud data will still be in iCloud). Next, go back to https://appleid.apple.com and change your primary email address and iCloud ID name back to the way it was. Now you can go to Settings>iCloud and sign in with your current iCloud ID and password.
-
I have not used my Apple TV in a few years, and just got it out of the bag to use on a new TV. I connected it up to power and with an HDMI cable toTV. It attempts to set date and time and cannot. I cannot get the remote to interact with the box also. Could it be something as simple as needing a new battery?
Hi kybriar,
Thanks for using Apple Support Communities. This article has steps you can take to troubleshoot the remote itself:
Troubleshooting the Apple Remote
http://support.apple.com/kb/ht1722
For the issue of setting the date and time, these articles may help:
Apple TV: Basic troubleshooting
http://support.apple.com/kb/ht1551
Reset Apple TV by unplugging it from the power outlet, waiting about five seconds, then plugging it in again.
Power off your TV, wait five seconds, then power it back on.
Apple TV (2nd and 3rd generation): Troubleshooting Wi-Fi networks and connectionshttp://support.apple.com/kb/TS4546
Ensure that Apple TV is within range of your Wi-Fi router or base station.
Confirm that your Wi-Fi router and cable/DSL modem are connected to power and turned on.
Make sure other devices (computers, iPhone, iPad, for example) are able to connect to the Wi-Fi network and access the Internet.
Check your Wi-Fi network settings on Apple TV:
Select Settings > General > Network > Wi-Fi and press the center button on the remote to display nearby networks.
Choose your Wi-Fi network from the list.
If your Wi-Fi network uses a password, make sure you are entering it correctly.
Restart your Apple TV by selecting Settings > General > Restart.
Try restarting your Wi-Fi router or modem by turning it off and then on again.
If possible, connect an Ethernet cable and verify your Internet connection. If you can connect to the Internet using an Ethernet connection, verify that your Apple TV is using the latest software by selecting Settings > General > Software Update. If your Apple TV can be updated, install the update and then try the steps again.
Cheers,
- Ari -
how do i get all my data and info from my old iphone onto my new one without access to the original itunes that i set my first iphone up on? my partners itunes keeps telling me that its going to replace all my apps and data with his stuff
ok so i have my own i tunes library - how do i get all my old apps onto my new library?
-
Formatting a date field auto populated with Javascript
I have a date field, which I auto-populate to be the current days date with the following code:
var date=new Date();
var month=date.getMonth()+1;
this.rawValue=month+"/"+date.getDate()+"/"+(date.getYear()-100);
This works fine, but it comes out as 7/20/12 instead of 07/20/2012 like my pattern defines.
Whether or not I write my code to be the correct format, I always get an "Invalid format" error. How can I fix this?The solutions is to format the date in YYYY-MM-DD when setting the raw value.
var date=new Date();
var month=date.getMonth()+1;
var day=date.getDate();
if(month<10){ month="0"+month; }
if(day<10) {day="0"+day; }
this.rawValue=date.getFullYear()+"-"+month+"-"+day; -
Setting User Preferences With Javascript In Acrobat X
Hi All,
Is there a way thru Javascript to programatically set a value in the User Preferences?
I am trying to create a batch sequence that exports PDFs to HTMLs. In the Acrobat X preferences, there is a conversion option that sets the option of "Run OCR If Needed" to true or false.
Edit --> Preferences --> Convert From PDF --> HTML --> Run OCR if needed (True|False)
Depending on conditions, I need to programtically set the value of this preference during the batch sequence before I export the document to HTML. Is this possible? Any help would be greatly appreaciated.
Thank you,
TeriThere are very few user preferences that can be controlled with JavaScript, and this isn't one of them.
-
How to extract data from XML file with JavaScript
HI All
I am new to this group.
Can anybody help me regarding XML.
I want to know How to extract data from XML file with JavaScript.
And also how to use API for XML
regards
NagarajuThis is a Java forum.
JavaScript is something entirely different than Java, even though the names are similar.
Try another website with forums about JavaScript.
For example here: http://www.webdeveloper.com/forum/forumdisplay.php?s=&forumid=3
Maybe you are looking for
-
Can't delete disk volume or files
I was using DVD2oneX using the join and create image functions. It created a disk volume and started copying all of my desktop files into it. I have only read access to the volume so I cannot delete the volume or any files that are in it. It is takin
-
ABAP Proxy does not send data to XI system.
I have a very simple program to test an ABAP Proxy: REPORT Z_TEST_PERSON_OB. DATA prxy TYPE REF TO Z996CO_PERSON_OB2. CREATE OBJECT prxy. DATA person TYPE Z996PERSON_MT . *TRY. person-person_mt-first_name = 'Ken and Kenneth'. person-person_mt-Serie
-
Stream iTunes from Mac to iPhone
Hi I want to stream iTunes via Wi-fi from my Mac to my iPhone and have both playing at the same time, so that I can have music playing via the Mac in one room and that same music playing simultaneously on my phone in another. I have set up Home Shari
-
Hi, I am not sure if this has been talked about already. I read the help with this but my phone is my own personal phone. Does anybody know how to fix this.... Running latest version of desktop software. Thanks, Todd
-
Script remove archives from standby after applied
Hello, I am looking for a script to remove archivelog files from the standby flash recovery area after beeing applied. My database is 11.2.0.3.3 on Linux Redhat 5. Can someone kindly proovide me an example? Thank you