|
Praveen Kandari wrote: I want Sorry, but this site does not provide to order.
|
|
|
|
|
Working on a website in Node.JS, and I've been doing good so far, but I've hit an error that has me stumped.
TypeError: Cannot set property 'isSubmitted' of undefined
at app.post.res.locals.showform (/media/sf_Node.js/SmartCage2/user.js:76:25)
at Layer.handle [as handle_request] (/media/sf_Node.js/SmartCage2/node_modules/express/lib/router/layer.js:95:5)
at next (/media/sf_Node.js/SmartCage2/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/media/sf_Node.js/SmartCage2/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/media/sf_Node.js/SmartCage2/node_modules/express/lib/router/layer.js:95:5)
at /media/sf_Node.js/SmartCage2/node_modules/express/lib/router/index.js:277:22
at Function.process_params (/media/sf_Node.js/SmartCage2/node_modules/express/lib/router/index.js:330:12)
at next (/media/sf_Node.js/SmartCage2/node_modules/express/lib/router/index.js:271:10)
at jsonParser (/media/sf_Node.js/SmartCage2/node_modules/body-parser/lib/types/json.js:100:40)
at Layer.handle [as handle_request] (/media/sf_Node.js/SmartCage2/node_modules/express/lib/router/layer.js:95:5)
The section that's throwing the error:
app.get('/login', function (res, req) {
res.locals.isSubmitted = false;
res.render("user/login.html");
});
The odd thing is, I use the same code above this, and it works.
app.get('/register', function(req,res) {
res.locals.isPosted = false;
res.render("user/register.html");
});
I have the forms submitted to the corresponding page (/login to /login, /register to /register), and I use the Nunjucks template system to show relevant data depending on how whether it was accessed via GET or POST.
I have no idea why it would be throwing the error on one section, but not the other.
I do, however, want to note that I barely know Javascript. I've always used strongly typed languages. I don't even like using 'var' in C#.
|
|
|
|
|
Vouksh wrote: I barely know Javascript Nor me, but the implication of that message is that your res object has not been initialised correctly.
|
|
|
|
|
Wow, I feel like an idiot. I glanced back over my code... and I had the 'req' and 'res' vars reversed.
But I likely wouldn't have noticed if you didn't point out something with the variables.
|
|
|
|
|
Vouksh wrote: I feel like an idiot. Something we have all had to admit from time to time.
|
|
|
|
|
Hello,
I am trying to built a kind of site where users can get data from database. Below you can see the
<a href="http://visitberat.com.al/MyNutri/NutriFacts">Site.</a>
Intro: Users through search form can search a category.
After submitting their request, they will be able to see all categories that contain the keyword.
If user wants to get more information for a specific product, they can select a checkbox and more data will be shown like the image provided within this<a href="http://i.imgur.com/9qGgHJk.png">link.</a>
Database is a single table with 52 columns. In the first search are shown only two colums. Other columns have to be posted after checkbox is selected.
Below you will find my code.
<pre lang="PHP"><html>
<head>
<title>Home | Mynutrifacts</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/font-awesome.min.css" rel="stylesheet">
<link href="css/animate.min.css" rel="stylesheet">
<link href="css/lightbox.css" rel="stylesheet">
<link href="css/main.css" rel="stylesheet">
<link href="css/responsive.css" rel="stylesheet">
<!--[if lt IE 9]>
<script src="js/html5shiv.js"></script>
<script src="js/respond.min.js"></script>
<![endif]-->
<link rel="shortcut icon" href="images/ico/favicon.ico">
</head>
<body>
<body>
<header id="header">
<div class="container">
<div class="row">
<div class="col-sm-12 overflow">
<div class="social-icons pull-right">
<ul class="nav nav-pills">
<li><a href=""><i class="fa fa-facebook"></i></a></li>
<li><a href=""><i class="fa fa-twitter"></i></a></li>
<li><a href=""><i class="fa fa-linkedin"></i></a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="navbar navbar-inverse" role="banner">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">
<h1><img src="images/logo.jpg" alt="logo"></h1>
</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li>
<form name="frmSearch" id="tfnewsearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>">
<table width="305">
<tr>
<th>
<input name="txtKeyword" type="text" id="txtKeyword" class="tftextinput" value="<?=$_GET["txtKeyword"];?>">
<input type="submit"class="tfbutton" value="Search"></th>
</tr>
</table>
</form>
</li>
<li class="active"><a href="index.php">Home</a></li>
<li><a href="aboutus.html">About</a></li>
<li><a href="contact.html">Contact us</a></li>
</ul>
</div>
</div>
</div>
</header>
<!--/#header-->
<section id="services">
<div class="container">
<div class="row">
<div class="col-sm-4 text-center padding wow fadeIn" data-wow-duration="1000ms" data-wow-delay="300ms">
<div class="single-service">
<div class="wow scaleIn" data-wow-duration="500ms" data-wow-delay="300ms">
<div id="tfheader">
<div class="tfclear"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<?
if($_GET["txtKeyword"] != "")
{
$objConnect = mysql_connect("localhost","etlevabi_search","prova1990") or die(mysql_error());
$objDB = mysql_select_db("etlevabi_search");
// Search By Name or Email
$strSQL = "SELECT * FROM food WHERE (description LIKE '%".$_GET["txtKeyword"]."%')";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 4; // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
$strSQL .=" order by foodid ASC LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
?>
<table width="600" border="1" id="mytable">
<tr>
<th width="91"> <div align="center">Food ID </div></th>
<th width="98"> <div align="center">Description </div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td> <input name="check_list[]" type="checkbox" value="<?=$_GET["txtKeyword"];?>"><?=$objResult["foodid"];?></td>
<td><?=$objResult["description"];?></td>
</tr>
<?
}
?>
</table>
<br>
Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page :
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtKeyword=$_GET[txtKeyword]'><< Back</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtKeyword=$_GET[txtKeyword]'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtKeyword=$_GET[txtKeyword]'>Next>></a> ";
}
mysql_close($objConnect);
}
?>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/lightbox.min.js"></script>
<script type="text/javascript" src="js/wow.min.js"></script>
<script type="text/javascript" src="js/main.js"></script>
</body>
</html></pre>
Thank you in advance!
|
|
|
|
|
Why does anyone use jQuery for AJAX calls? In fact, for a lot of things? OK, there's no point in reinventing the wheel, and people have built some nice things with it, notably photo sliders/ carousels etc, but for so many things - and AJAX is a case in point - good ol' vanilla JavaScript is so much easier! A number of times now I've looked at using jQuery for AJAX, and given up in frustration. No more.
Sledgehammers and nuts come to mind.
|
|
|
|
|
Wombaticus wrote: for so many things - and AJAX is a case in point - good ol' vanilla JavaScript is so much easier!
Really?
if (window.XMLHttpRequest) {
httpRequest = new XMLHttpRequest();
} else if (window.ActiveXObject) {
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
httpRequest.onreadystatechange = function() {
if (httpRequest.readyState == 4 && httpRequest.status == 200) {
var result = httpRequest.responseText;
}
};
httpRequest.open("GET", theUrl, true);
httpRequest.send();
vs:
$.ajax({
url: theUrl
}).done(function(result){
});
Also, the jQuery version[^] has a lot of built-in functionality which you would have to reimplement if you wanted to use it in the plain Javascript version.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Well.. see my reply to F-ES Sitecore below.... (if you feel so inclined ...)
|
|
|
|
|
One of the nice things about jQuery is that it hides per-browser implementation from the client; you don't need to know the differences between how IE\Chrome\FireFox implements ajax, or even if there are differences in how individual versions work. People also keep jQuery up-to-date again so you don't have to. Add to that the syntax is much easier as Richard has already pointed out, and it has nice features you'd have to code yourself such as making "get" calls non-cached etc.
If the only reason you're using jQuery is for ajax then you might have a point, but if I'm honest even if ajax was all I was doing I'd probably still use jQuery as it is lightweight and you'll probably end up using the other features anyway.
|
|
|
|
|
Well, I don't find the syntax (or documentation) clear at all.
Maybe I should turn this into a question: how would you, for example, "jQueryify" this?
if (window.XMLHttpRequest) {
rQM = new XMLHttpRequest();
} else if (window.ActiveXObject) {
rQM = new ActiveXObject("Microsoft.XMLHTTP");
}
function getPage(p, tImg, iImg, t, s, h) {
var r = new Date().getTime();
var url = 'pagebox.ashx?p=' + p.toString() + '&r=' + r.toString();
rQM.open("GET", url, true);
rQM.onreadystatechange = function () {
UpdateScreen(p, tImg, iImg, t, s, h);
}
rQM.send(null);
}
function UpdateScreen(p, tImg, iImg, t, s, h) {
if (rQM.readyState == 4) {
var response = rQM.responseText;
if (response != '') {
var params = response.split("|");
document.getElementById(tImg).value = 'userfiles/' + params[0];
document.getElementById(iImg).src = 'userfiles/' + params[0];
document.getElementById(t).value = params[1];
document.getElementById(h).value = params[2];
tinyMCE.get(s).setContent(params[3]);
}
}
}
(tinyMCE references the tinyMCE HTML editor[^])
To me, that is pretty easy to grok - I've tried over and over to work out how to do it in jQuery and, as I say given up each time in despair...
(And, yes, I know it's a little ugly in the return - I should probably return the data as XML or JSON, but it works well enough for my purposes.)
|
|
|
|
|
Something like this should work:
function getPage(p, tImg, iImg, t, s, h) {
$.get({
url: 'pagebox.ashx?p=' + p.toString(),
cache: false
}).done(function(response) {
updateScreen(p, tImg, iImg, t, s, h, response);
});
}
function UpdateScreen(p, tImg, iImg, t, s, h, response) {
if (response != '') {
var params = response.split("|");
document.getElementById(tImg).value = 'userfiles/' + params[0];
document.getElementById(iImg).src = 'userfiles/' + params[0];
document.getElementById(t).value = params[1];
document.getElementById(h).value = params[2];
tinyMCE.get(s).setContent(params[3]);
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
As simple as that, huh...?
sigh...
|
|
|
|
|
I can't figure out how to do the following with javascript:
- user enters a url for an html page e.g. Start.html
- on that html page there is link the user needs to click
When the user clicks that link I want to:
- reload the current browser window (NOT open new browser window or a new tab) with the url of some aspx page
- remove any browser related menus/buttons and the URL textbox.
Here is what I have in the html body:
Login
Here is the associated javascript:
function openClient() {
clientWindow = window.open('Login.aspx?p=1','_self','directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
}
The part about loading the asp page in the same browser window works fine. The part that's not working is removing all the browser related buttons and the URL textbox. I can still see the URL textbox.
Can anyone please help?
thanks,
|
|
|
|
|
You can't. If it was possible for script to hide the URL, menus and toolbars, every malicious site on the net would do it.
Even if you open the page in a new window, most browsers will still show the URL.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I have an old javascript that works in both IE and Firefox but it's for a new browser window, not a current one. So, there is no way to do it for the current browser window? What about by using css to hide it? Any way to disable it?
|
|
|
|
|
Not without a browser extension installed on the system that you want to do this on.
It's a terrible idea, by the way.
|
|
|
|
|
IE has a setting to show the address bar even with the code you have. So, the real answer is no, there is no way to ensure it. It will depend on which browser the user is using and what their settings are.
However, what you can do is create a div on your page that has all the same controls and then can easily display that using jquery ui's dialog feature. See Dialog | jQuery UI[^].
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
|
Yes and No.
You could do this in some browsers however what you are trying to do is out of your control. You have no control over what extensions , versions and plugins of the browsers the client computer has got.
You need to review your requirement and take an alternative route for what you are trying to achieve.
|
|
|
|
|
am using the following code
$("#div_id").dialog({
title: "Enter your Password",
autoOpen: false,
height: 150,
width: 250,
modal: true,
show: 'drop',
hide: 'drop',
open: function() {
document.getElementById("<%=txt_password.ClientID %>").value = "";
},
buttons: {
"Confirm": function() {
debugger;
var password = document.getElementById("<%=txt_password.ClientID %>").value;
}
}
});
here after entering the text in text box of dialog box..i need to press tab or use the mouse to click confirm button..
my requirement is: After entering text in textbox ,just press the enter button ..how to focus the confirm button like that
here div_id:
<div id="div_password">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<asp:Label ID="lblpassword" runat="server" Text="Password" Font-Bold="true" /></td>
<td>
<asp:TextBox ID="txt_id" runat="server" Enabled="true" Width="100px" TextMode="password" Text="">
</asp:TextBox>
</td>
</tr>
</table>
</div>
modified 24-Mar-16 2:35am.
|
|
|
|
|
|
I have following row data in a json file:
{rows:[
{id:1,data:["1","A","10"]}
,{id:2,data:["2","B","50"]}
,{id:3,data:["3","C","60"]}
,{id:4,data:["4","D","70"]}
,{id:5,data:["5","E","90"]}
,{id:6,data:["6","F","2"]}
,{id:7,data:["7","G","4"]}
,{id:8,data:["8","H","50"]}
,{id:9,data:["9","B","100"]}
,{id:10,data:["10","A","60"]}
,{id:11,data:["11","K","0"]}
,{id:12,data:["12","L","20"]}
]}
I was wondering if I can get a kick start suggestion to write our own group by function to group on any column. Like in above example, we can use the second column to group by.
The only restriction I have is that I can't use jquery and have to use java script only.
Need expert help...
|
|
|
|
|
You can overload the standard Array.sort() in the same manner as a standard comparative operation.
The problem that you have is that your rows are not properly formatted for JSON (it looks like your data value should be an object, not an array) and you're mixing strings and integers. If you ONLY want to group by 1 field that's easy, if you want flexibility then you'll have a more complicated operation on your hands. One sort function will not be suitable for your needs, since string comparisons in Javascript will give you wonky results when used on stringified numbers, and using numerical comparisons on strings will also give bad data.
Array.prototype.sort() - JavaScript | MDN[^] has a bunch of suggestions for how to handle sorting of various data types and uses vanilla Javascript.
|
|
|
|
|
I have an AngularJS view that contains a ng-grid row cellTemplate icon button. The problem only happens in IE and not in Google Chrome. When the user selects the icon button a ngDialog is opened and on the dialog close event the dialog closes then the selected icon button increases in size in the cell and all of the text in that row shifts up and to the left. I have tested this in Google Chrome and the problem does not occur. What I am seeing is that the entire browser seems to do a shift to the right then back when I do close the dialog. It was recommended to me that on dialog close I close the dialog then redirect to a dummy view which redirects back to reload the view with ng-grid. I tried that but am unable to get working.
The dialog definition, and the cellTemplate markup the contains the icon button that calls the open dialog event is shown below along with the dialog open and close event
<script type="text/ng-template" id="ApproverCommentsDialog">
<div class="ngdialog-message">
<h3>Approver Comments</h3>
<p>
({ApproverComment}}
</p>
</div>
<div id="gridDiv" class="ngdialog-buttons">
<button type="button" ng-click="OKClicked()" class="ngdialog-button ngdialog-button-primary">OK</button>
</div>
</script>
var = cellTemplateIconWithTooltip = '<div class="ngCellText" ng-class="col.colIndex() - 1"><a title="Show" ng-click="displayComments(row.entity)"><img src="../../../../Content/images/managerequests.png" style="float: right; padding:5px; border:3px" height="20px" width="20px" /></a></div>';
$scope.displayComments = function (row) {
$scope.ApproverComment = row.ApproverComments;
ngDialog.open({
template: 'ApproverCommentsDialog',
className: 'ngdialog-theme-default',
data: row.ApproverComments,
scope: $scope
});
};
$scope.OKClicked = function () {
ngDialog.close();
};
Any help would be great.
modified 14-Mar-16 12:12pm.
|
|
|
|
|