|
how I can use a variable passed by parameter in a javascript function in a lambda expression?
p.s: name of the variable = xyz
Code:
pendencias.push(@Model.Count(x => (x.FC_VH_OWNER_STATE_NM == "SP" && Convert.ToDateTime(x.FD_REQ_SERVICE_VALIDITY_DT) <= Convert.ToDateTime(System.DateTime.Now).AddDays(xyz))));
ERROR: Variable is not found
|
|
|
|
|
I am having a little issue, with getting dates to show up in desired (dd-mm-yyyy) format, however they are displayed as 'NaN Nan' on the line chart x-axis. I have added in a 'parseInt' date format but I am not sure if this is a correct approach.
Please advice. Many thanks for your help and time.
function drawVisualization(dataValues, chartTitle, columnNames, categoryCaption) {
if (dataValues.length < 1)
return;
var data = new google.visualization.DataTable();
data.addColumn('string', columnNames.split(',')[0]);
data.addColumn('number', columnNames.split(',')[1]);
data.addColumn('string', columnNames.split(',')[2]);
data.addColumn('datetime', columnNames.split(',')[3]);
for (var i = 0; i < dataValues.length; i++) {
var date = new Date(parseInt(dataValues[i].Date.substr(6), 10));
data.addRow([dataValues[i].ColumnName, dataValues[i].Value, dataValues[i].Type, date]);
}
var dateFormatter = new google.visualization.DateFormat({ pattern: 'dd MM yyyy' });
var line = new google.visualization.ChartWrapper({
'chartType': 'LineChart',
'containerId': 'PieChartContainer',
'options': {
'width': 950,
'height': 450,
'legend': 'right',
'hAxis': {
'format': "dd-MM-yyyy",
'hAxis.maxValue': 'viewWindow.max',
'maxValue': new Date(2014, 05, 30), 'minValue': new Date(2014, 04, 05),
'viewWindow': { 'max': new Date(2014, 05, 30) },
},
'title': chartTitle,
'chartArea': { 'left': 100, 'top': 100, 'right': 0, 'bottom': 100 },
'tooltip': { isHtml: true }
},
'view': {
'columns': [{
type: 'string',
label: data.getColumnLabel(3),
calc: function (dt, row) {
var date = new Date(parseInt(dt.getValue(row, 3)));
return dateFormatter.formatValue(date);
}
}, 1, {
type: 'string',
role: 'tooltip',
calc: function (dt, row) {
return 'Name: ' + dt.getValue(row, 0) + ', Decimal Price: ' + +dt.getValue(row, 1) + ', Date: ' + +dt.getFormattedValue(row, 3);
}
}]
}
});
new google.visualization.Dashboard(document.getElementById('PieChartExample')).bind([categoryPicker], [line]).draw(data);
}
|
|
|
|
|
miss786 wrote: however they are displayed as 'NaN Nan' on the line chart x-axis. The reason is the value is not a numeric.
miss786 wrote: I have added in a 'parseInt' date format but I am not sure if this is a correct
approach. I think you're getting NAN because you're getting an empty string or null & parsing directly. Just check the result of parseInt("") or parseInt(null)
So check the value before sending to Date function. Debug there.
|
|
|
|
|
Apology for the late response. Thank you very much for your feedback. I manage to get the date value pass the parseInt but however, now I am getting a blank screen on the client-end, with the following warning in the console debug of my chrome browser:
event.returnValue is deprecated. Please use the standard event.preventDefault() instead. --> warning
<script type="text/javascript">
function drawVisualization(dataValues, chartTitle, columnNames, categoryCaption) {
if (dataValues.length < 1)
return;
var data = new google.visualization.DataTable();
data.addColumn('string', columnNames.split(',')[0]);
data.addColumn('number', columnNames.split(',')[1]);
data.addColumn('string', columnNames.split(',')[2]);
data.addColumn('datetime', columnNames.split(',')[3]);
for (var i = 0; i < dataValues.length; i++) {
var date = new Date(parseInt(dt.getValue(row, 3)));
data.addRow([dataValues[i].ColumnName, dataValues[i].Value, dataValues[i].Type, date]);
}
var categoryPicker = new google.visualization.ControlWrapper({
'controlType': 'CategoryFilter',
'containerId': 'CategoryPickerContainer',
'options': {
'filterColumnLabel': columnNames.split(',')[2],
'filterColumnIndex': '2',
'ui': {
'labelStacking': 'horizontal',
'allowTyping': false,
'allowMultiple': false,
'caption': categoryCaption,
'label': 'Price Type',
}
}
});
var dateFormatter = new google.visualization.DateFormat({ pattern: 'dd MM yyyy' });
var line = new google.visualization.ChartWrapper({
'chartType': 'LineChart',
'containerId': 'PieChartContainer',
'options': {
'width': 950,
'height': 450,
'legend': 'right',
'hAxis': {
'format': "dd-MM-yyyy",
'hAxis.maxValue': 'viewWindow.max',
'maxValue': new Date(2014, 05, 30), 'minValue': new Date(2014, 04, 05),
'viewWindow': { 'max': new Date(2014, 05, 30) },
},
'title': chartTitle,
'chartArea': { 'left': 100, 'top': 100, 'right': 0, 'bottom': 100 },
'tooltip': { isHtml: true }
},
'view': {
'columns': [{
type: 'string',
label: data.getColumnLabel(3),
calc: function (dt, row) {
var date = new Date(parseInt(dt.getValue(row, 3)));
return dateFormatter.formatValue(date);
}
}, 1, {
type: 'string',
role: 'tooltip',
calc: function (dt, row) {
return 'Name: ' + dt.getValue(row, 0) + ', Decimal Price: ' + +dt.getValue(row, 1) + ', Date: ' + +dt.getFormattedValue(row, 3);
}
}]
}
});
new google.visualization.Dashboard(document.getElementById('PieChartExample')).bind([categoryPicker], [line]).draw(data);
}
Please advice, if possible. Many thanks.
|
|
|
|
|
miss786 wrote: event.returnValue is deprecated. Please use the standard event.preventDefault() instead. --> warning That's warning, possibly you're using new jQuery version. Try previous(your project's) version.
|
|
|
|
|
|
Hi,
How to disable JqueryDateTime Picker Image button .
But textbox i can disable ,I can't do Image button.
here code i am try it.
function disableDate() {
debugger;
document.getElementById('txtStartDate').disabled = true;
$get('txtStartDate').style.color = "gray";
$get('txtStartDate').disabled = true;
$('txtStartDate').datepicker('disable');
$('txtStartDate').datepicker('setDate', new Date()).datepicker('disable').blur();
$('txtStartDate').disableSelection = true;
}
<input id="txtStartDate" runat="server" class="TextBox DatePicker"
style="width: 125px" />
<style>
.ui-datepicker-trigger
{
position: relative;
top: 4px;
right: -3px;
height: 17px;
}
</style>
<script language="javascript" type="text/javascript">
var Dformat = "";
$(document).ready(function () {
var selectvalStartDate = $("#txtStartDate").val();
var sVal = document.getElementById('hdnPORTALID').value;
Dformat = GetDatePickerFormat(sVal);
$(".DatePicker").attr("placeholder", "Select date").datepicker({
showOn: "both",
buttonImage: "../images/datepicker_enable.png",
buttonImageOnly: true,
changeMonth: true,
changeYear: true,
dateFormat: Dformat
});
});
</script>
thanks,
Karthikeyan,
|
|
|
|
|
Hi,
I am not sure whether this would work, but,
can you try this ?
<input name="date" id="datepicker" disabled="disabled" />
$('#datepicker').datepicker();
For further could you please check this link:-
https://forum.jquery.com/topic/disabled-datepicker[^]
Regards,
Praneet
|
|
|
|
|
$("txtStartDate").datepicker({
disabled:true
});
modified 9-May-14 14:36pm.
|
|
|
|
|
Can anyone provide me design or flow to create application for formula builder or expression builder using java-script. just like a calculator but little advanced. which can read any mathematical expression.
ex:
(a+b)/c
5*LOG(1000)* -2/3
MAX(4, 6%7)
(-2*(4*5)+4)/2 -6
|
|
|
|
|
|
You can use Javascript method eval().
It can evaluate functions and expressions as a string.
Life is a computer program and everyone is the programmer of his own life.
|
|
|
|
|
Hi ,
I have an html page for showing google maps. It is showing fine in chrome and firefox, but not in IE. How to fix this ?
Here is the page I used
<title>Google Maps Multiple Markers
var locations = [
['Bondi Beach', -33.890542, 151.274856, 4],
['Coogee Beach', -33.923036, 151.259052, 5],
['Cronulla Beach', -34.028249, 151.157507, 3],
['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
['Maroubra Beach', -33.950198, 151.259302, 1]
];
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: new google.maps.LatLng(-33.92, 151.25),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
}
|
|
|
|
|
|
please embed your code with < pre > tags. (the code button in the toolbar when editing/writing a post)
like this...
Code here. You can choose between different language settings HTML / XML / ASP and javascript is what you should use here in your case ...
hope this helps.
|
|
|
|
|
I'm having an issue with the legend options of JQPlot.
I can do some things with the legend like defining the labels (array legendlabels), showSwatches and placement and location.
But any attempt in changing the background, textColor or fontSize, ... doesn't work. The plot shows, the legend shows, but none of these options work. I've been up and down the provided samples and they work. I compared them with my prototype here (also all the css and js includes), but still no dice.
The code doesn't seem wrong as the plot (and legend) show, but some of the options don't seem to do anything.
legend: {
show: true,
labels:legendlabels,
location:"n",
rendererOptions: {
placement:"outsideGrid",
textColor: "rgb (255, 100, 100)",
fontSize: "18pt"
}
},
has anyone encountered this issue? How can I solve this?
(google's results didn't yield solutions for me either)
thanks!
[SOLUTION]
You need to add the correct javascript file at the bottom of the page:
<script class="include" type="text/javascript" src="./Scripts/JQPlot/plugins/jqplot.enhancedLegendRenderer.js"></script>
and use the
renderer:$.jqplot.EnhancedLegendRenderer,
option in the json definition.
then you place any css styling properties in the
rendererOptions: {}
object.
[/SOLUTION]
modified 23-Apr-14 9:27am.
|
|
|
|
|
I have been trying to add the salutation string to p id="salutation" I can't figure it out. I have to use a html and a script separate this is what I have for the HTML.
<html>
<head>
<title>Invitation</title>
<meta charset="utf-8">
</head>
<body>
<p id="salutation">
</p>
<p id="image"></p>
<p>You are invited to my house for a Cynco de Mayo party May 5, 2014.
</p>
<p>Sincerely,</p>
<p id="closingname"></p>
<script type="text/javascript" src="script\letter.js"></script>
</body>
</html>
And this is what I have for the .js:
"use strict";
function greeting() {
var textOne = "Dear";
var name = "John";
var punc = ",";
document.write(textOne + name + punc);
}
function complete() {
var yourName = "Gerald Blackmore";
var img = "<img src='image/partyimage.jpg'>";
greeting();
document.write(img);
document.write(yourName);
}
complete();
These are the teachers instructions:
Create the following web page and name it letter.html.
<html>
<head>
<title>Invitation</title>
<meta charset="utf-8">
</head>
<body>
You are invited to my house for a Cinco de Mayo party May 5, 2014.
Sincerely,
</body>
</html>
Download an image that is appropriate for a Cinco de Mayo celebration and save it in an appropriate place on your web site.
Create an external JavaScript file and name it letter.js. Add the appropriate <script> tag to letter.html to include this external JavaScript file.
In the external JavaScript file you are to create two functions and invoke them. The first function should:
Accept three arguments: a greeting, e.g. "Dear", "Hello", or "Greetings", first name, and any appropriate punctuation, such as "," or ":".
The function should return a single string that is the full salutation in greeting, first name, punctuation order, e.g., "Dear Mark:".
The second function should:
Accept three arguments, the salutation returned by the first function, the sender name which will be your name, and the image file name of your downloaded Cinco de Mayo image.
The function should then add the salutation string to the paragraph.
The function should then add the downloaded Cinco de Mayo image to the paragraph.
Finally, the function should add your name to the paragraph
|
|
|
|
|
You have got the wrong idea. This is a forum to answer specific programming problem, not to do someone's homework/assignment. We are not helping you if we do it for you. The assignment is meant to gauge your understanding of what you have learned, if we do it for you, we get the grade, not you. How are you going to pass your test/exam subsequently,let alone graduating. Remember, no effort no gain, and study hard.
|
|
|
|
|
As Peter said, we're not going to do your homework for you. However, it sounds like you just need a hint to push you in the right direction.
document.write [^] will write the string to the document at the point where the function is called. You want to insert the string into a specific element, which means you need to get that element by ID, and update its inner HTML.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you so much. a push the right way was exactly what I was asking for.
|
|
|
|
|
|
Thank you. That was very helpful.
|
|
|
|
|
is it possible to get a value from another page using JavaScript language?
|
|
|
|
|
how is the value stored in the other page? e.g. In a label or textbox?
|
|
|
|
|
any value of text. contained the numbers itself in actually.. That is text only!
|
|
|
|
|