function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
inanskarinanskar 

Representing java script value in Visualforce page

Hi  All,

I got an issue that how to represent a javascript variable like the below code myDate in visualforce page

 

<script language="JavaScript">
var myDate = new Date(document.getElementById("{!r.Invoice_Date__c}").value);
myDate.setMonth( myDate.getMonth() + 1 );
alert(myDate);
Document.write(myDate);

</script>

can u tell the tags for representing the mydate variable in visualforce Page

 

Thanks in Advance

IspitaIspita

Hi inanskar,

Do try the following :-

  • considering that you have a control / input text by the name "otherName" assign the javascript value as follows to that control of your VF page:-

       document.getElementById('{!$Component.otherName}').value=myDate.setMonth( myDate.getMonth() + 1 );

  You can assign the value to a VF hidden control which you can access in your controller when the page submits.

Hope this helps.