|
I am really sorry. I have been trying to solve this for long but still can't. I know the conditions and operators but i could not come up with the right one. you mention its not javascript question? why its not a javascript question? thanks
|
|
|
|
|
Start by writing the rules in natural language (from your question), something like:
Display a message
Read Speed value
If speed is greater than [ speed value 1 ]
Then
check values and issue fine
ElseIf speed is greater than [ speed value 2 ]
Then
check values and issue fine
...
Endif
Once you have that logic written down you can convert it to your programming language.
|
|
|
|
|
Refer to your JS lesson notes, especially those concern JS operators and conditions, and you should be able to complete your homework.
If for whatever reason, you do not have those notes, fret not. Check out some online tutorials, such as
JavaScript Operators[^] and JavaScript If...Else Statements[^]
Peter Leow
https://www.amazon.com/author/peterleow
|
|
|
|
|
I know those operators and condition but i can not use them in the right way would be happy if just give me a hints to write the first condition .. thanks
|
|
|
|
|
Where are you stuck?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I am adding html templates to actionmethods in views.and i have added JS folder,CSS folder.in route config file i have set index as main page.only for mainpage Jquery and css is applying but remaining pages it is not applying.if i changed route config file with another index2 css is applying on Index2.can you please tell me what are ways to solve this?
|
|
|
|
|
|
|
Hi All,
I have been trying to have file upload control in my portal using extJS, but failing.
I am using EXT JS version 2.2.
Below is the code I am using for file upload control.
{
xtype: 'fileuploadfield',
id: 'form-file',
fieldLabel: Text.MainAttachAttach,
labelSeparator: '',
name: 'uploadfile',
allowBlank: true
}
This is throwing error as this code is from EXT JS 3.2.1
How do I write same If I am using EXT JS 2.2
Please Help me if anybody has idea.
thanks,
Hemant
By:
Hemant Thaker
|
|
|
|
|
I need to play a local video file into a IE browser. I'm using internet explorer 11 version. I need to hide "save" and "save as" button in alert dialog box.
I've used
It works fine in the lower versions of IE, but not in IE10 and above.
|
|
|
|
|
|
I want a ISBT Barcode javascript for my asp.net application.
Please urgent TIA
|
|
|
|
|
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...
|
|
|
|
|