.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan
Post New Web Links

Set the DateTime field using javascript

Posted By:      Posted Date: September 17, 2010    Points: 0   Category :SharePoint
 
Hi everyone, I need Help in implementing a solution. I have 2 fields: Resolution Date (DateTime) and Severity (Dropdown) and I need depending on the choise in dropdown (0-3) set different dates into the DateTime field. The difficult part is that I can't realize how is to SET the date there %) Here is my code: var ExpDateResolved = $("input[title=Expected Resolution Date]").first(); $("select[title=Severity]").first().change(function(){ ExpDateResolved.val('); var chbReqSevDom = $(this).get(0); if (chbReqSevDom.selectedIndex == 0)  //first value in dropdown selected { var currentDate = new Date(); DateResolved.val(zeroPad(currentDate.getDate(),2) + '.' + zeroPad((currentDate.getMonth()+1),2) + '.' + currentDate.getFullYear()); } } P.S. I've tried to set a date into a Text field and it works.


View Complete Post


More Related Resource Links

Onchange event for datetime field in javascript is not working?

  

I want to compare start date and end date when start date is changed. If start date is big, on change event i need to make the end date the same as start date.

So I wrote On change event for start date. But it doesnot work  

getField('input','Start Time').onchange = function() {showEndDate()};

 

function showEndDate()

{

alert("test");

var date1 = getField('input','Start Time');

var date2 = getField('input','End Time');

}

but its not firing at all. So you guys have any idea or any other way to do for datetime on change event?


getting time and date from datetime field in javascript

  

Hello guys, I need to get hours from the difference between two datetime fields. I wrote the javascript which will get the date from datetime field.

But its not getting the correct time that entered on date time field. Its defaultly getting the current time on my system.

So do you guys have any idea. How to get time from date time fields. and how calculate hours between two datetime fields using javascript.


hide datetime field from NewForm of a list using javascript

  

I want to hide Datetime control (entire row) from Newform.aspx of a list using javascript. i am using the following code but its not working for Date time field  else its working fine for TextField.

var DateOfwin=document.getElementById(getTagFromIdentifier('input','DateTimeFieldDate','Date of Win').id);
DateOfProposal.parentElement.parentElement.parentElement.style.display='none';

(above code only hide the calander field i want to hide the entire row)

thanks



Mission Impossible? Use Javascript to Disable a Multi-Line Rich Text Field

  

Hey Community,

Here's a tough one that I have struggled with and so far have not been able to find an answer for - how do you use Javascript to disable a multi-line rich text field.  I have customized a SP Edit form by adding a CEWP.  In the CEWP I have added the Javascript below (only a partial code sample provided) to disable several fields in the form.  The code works fine for single line text fields but it does not work for multi-line rich text fields.  Any suggestions?

<script language="javascript">
//This runs the function when the form first loads
_spBodyOnLoadFunctionNames.push("lockFields");

//This locks the fields the users should not modify
function lockFields()
{
  var theInputTFTitle = getTagFromIdentifierAndTitle("Input","TextField","Title");
  theInputTFTitle.readOnly = true;
  theInputTFTitle.style.color = 'gray';
  //alert(" Value: " + theInputTFTitle.value);//for testing

   var theInputDDLReplyStatus = getTagFromIdentifierAndTitle("select","DropDownChoice","Reply Status");
  theInputDDLReplyStatus.disabled = true;
  //alert(" Value: " + theInputDDLReplyStatus.value);//for testing

  var theInpu

Comparing Datetime field in DB?

  
I need to check the datetime field in my DB to see if the time that's current set is 12hr's past? What's the command to use?  Can I just DATEDIFF? 

Flat file upload: Error when inserting into datetime field.

  
Hi All I am having an issue with uploading a txt file into an SQL table and one of the fields needs to go into a datetime column. The issue is with column3 I have been into the advanced editor of the flat file source and set the output column to decimal and it fails. The error I am getting is below: Error: 0xC02020A1 at Materials Transfer, Flat File Source [1]: Data conversion failed. The data conversion for column "Column 3" returned status value 2 and status text "The value could not be converted because of a potential loss of data.". Error: 0xC0209029 at Materials Transfer, Flat File Source [1]: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR.  The "output column "Column 3" (48)" failed because error code 0xC0209084 occurred, and the error row disposition on "output column "Column 3" (48)" specifies failure on error. An error occurred on the specified object of the specified component.  There may be error messages posted before this with more information about the failure. Error: 0xC0202092 at Materials Transfer, Flat File Source [1]: An error occurred while processing file "D:\Development\r3_downloads\mat.txt" on data row 1. Any help would be great.   Thanks BigGopher

Can I update Project Field value via some javascript?

  
Hi there, I've a webpart that's designed to update some project field value, this webpart is  located on a Project Details Pages. On this project details page, there is another MS Build-in webpart call Project Field webpart. Now when I clicked the Save ribbon button, the project field webpart will raise some client calls, at the same time my custom webpart will raise a post-back(update value via PSI) call which will kill the client calls..So is it possible for me update the project filed value via some javascript? so I'll no longer raise a postback. Or is it possible for me to capture the client calls event for MS webpart, then I can fired my own PSI code? Thank you,   Regards, Joe

javascript for field validation on a textbox...

  
I'm looking at doing the validation for the email in javascript since we have asp.net 1.1. I can get it to just alert fine, but once I add the return validation it doesn't fire. Me.ImageButton2.Attributes.Add("onclick", "return validation(this);") <script language="JavaScript"> <!-- function validation () { var test=""; test = document.ticketForm.emailAddress.value; if (test == "xyz") { alert(test); return false; // validation failed } --> </script>

Showing the value as blank in a grid view when the Datetime field in SQL has its minimum value

  
Hi,Developing an application in C#.Retrieving data using SQL server. A record has a datetime field( eg: Resigned Date). If the datetime field in null in my code I will have the minimum value stored in the database which is "1/1/1900" ( eg: for current employees as they do not have a resigned date this field will have the 1/1/1900 value as I cannot leave this blank)Now when I'm displaying the employee records in a gridview in my application it shows the 1/1/1900 value for the "Resigned Date" field. I need this to be blank.Here is the code that I have done so far...void GetRecords(){DBConnect db = new DBConnect();DataSet ds = new DataSet();ds = db.getDataForgrid("Select * from Employee");DataTable dt = ds.Tables[0];GridView1.DataSource = dt;GridView1.DataBind();}Please help.Thanks

Passing hidden field ASP.net to javascript

  
Hi!   I have in my project an button that when is press need to verify if the aplication has been save. If the app no save, then popup a message (confirm box) to ask user yes or no to continue.   Hi have in my asp code a hidden field that gives me if the app is saved ou not, and I have this javascript function that I atach to my button onclientclick function.  <asp:HiddenField ID="HIdCab" runat="server" />    <asp:Button ID="BtnRetomar" runat="server" CausesValidation="False" CssClass="botao" Text="Retornar" Width="85px" onclientclick="" />   <script type="text/javascript" language="javascript">function MyRetornar(){    var myId = document.getElementById("<%=HIdCab.ClientID%>");                if (myId==null)    {               return confirm('Quer retornar SEM GRAVAR a aplicação actual?');   }    else    {        return true;     }}                   <

Formatting datatable datetime field

  
I am getting an error message:Conversion from string "mm/dd/yyyy" to type 'Integer' is not valid.  What is best way to format date filed from datatable without showing the time?   ClosingDate is smalldatetime in my SQL DB. ThankslblClosingDate.Text = dt.Rows(0).Item("ClosingDate").ToString("mm/dd/yyyy")

Javascript price update ...hidden field ... asap

  
Hello Experts http://store.apple.com/us/configure/MC374LL/A?mco=MTc0Njg1ODA Like in this link i created a javascript function  === id , lenght , width , dept , capacity ,price ..<script type="text/javascript">function getproductdetail (id,len,wid,dep,cap,thick,prc)     {          document.getElementById('row1')=prc   }          </script>the same function is called at a new place where i pass only price .. i have to check if there is a price is present in 'row1' i have to add new prc to present one .. =================== thing is where i will retain the old value present .. How to check whether value is prsent in row1 or not ..... if i will choose hidden field where to use and how to check value for that ... Thanks

error calling javascript in grid view template field

  

I am using a asp link button in grid template field which calls a pop up,i need to find the link button's control in cs page.

my link button code

<asp:LinkButton runat="server" ID="hlQName" Text='<%# Eval("QuestionnaireName")%>' OnClientClick

Set Default Value of BDC Field with Javascript

  
I have customized a newform.aspx page for a list. The form has a couple of BDC fields, one of which I'm trying to set a default value. I have a javascript using jquery that sets the default value of several regular text fields but I cannot get the function to work with the BDC field. I have the following code:
function setDefault() {
var variety = "blue";

var elem = getBDCTagFromIdentifierAndTitle("TEXTAREA","Object Picker", 1);
if(elem) elem.value = variety;
var elem = getBDCTagFromIdentifierAndTitle("DIV","Object Picker", 1);
if(elem) elem.innerText = variety;

}

function getBDCTagFromIdentifierAndTitle(tagName, title, count) {
  var tags = document.getElementsByTagName(tagName);
  var myCount = 0;
  for (var i=0; i < tags.length; i++) {
    var tempString = tags[i].id;
    if (tags[i].title == title){
      myCount++;
      if(count == myCount){
        return tags[i];
      }
    }
  }
  return null;
}
This shows the value in the field, but when I save the form, the field does not save the value. My regular text fields that have a default value set do save, just not the BDC field. I've verified that the getBDCTagFromIdentifierAndTitle function does return valid objects and their value/innerText are indeed being set.

Any suggestions? is there a better way of setting the default v

Return year only from datetime field

  

Using SQL Server 2005.

I need to return the year only from a datetime field and then group by that field, does anyone know the syntax for this?

thanks

MC


filling current user name in people picker field when loading form using javascript

  

Hello guys,

I am looking is there any way to fill the current user's name in people picker field in newform.aspx using javascript?

If you anything, please let me know 

thanks


javascript alert window when dropdown field is selected,

  

hi

is there a way..where an alert window prompts up to remind the user to select a checkbox when one field in dropdown is selected..for example

there is a dropdown field(Status)  which contains (Tobe confirmed, confirmed and rejected ), when confirmed is chosen..an alert window prompts up reminding the user to select a checkbox(send email) - Yes or No. It is not compulsory for the user to select the checkbox, but if Yes is chosen, the workflow will send an email


Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend