I am having problems trying to insert this function into this piece of code below. - var pages=['www.lboro.ac.uk:degree programmes','channel4.co.uk', 'www.bbc.co.uk:sports', 'www.skynews.com:the best election']
-
var w='degree'
-
var p=0
-
if(pages[p].indexOf(w)<0)
-
alert ('not found')
-
else
-
alert('found')
i want to use the function find_1(w,p) - to discover if the string w appears in the string pages[p]. Gives an alert of w 'found' or 'not found'. but when i put the function, it doesn't run
7 1164
You don't have Java problems, you have Javascript problems; those two languages
are not the same no matter their name similarity. Do you want me to move your
question over to the .NET forum where such questions are answered?
kind regards,
Jos (moderator)
whats wrong in it its working fine
gits 5,390
Expert Mod 4TB
what do you mean with 'put the function' ... where do you include/call it?
kind regards
i think you need brackets for else.
thus: - if(pages[p].indexOf(w)<0)
-
alert ('not found')
-
else
-
alert('found')
should be - if(pages[p].indexOf(w)<0){
-
alert ('not found')
-
}else{
-
alert('found');
-
}
gits 5,390
Expert Mod 4TB
unless there is just one, and only one, statement, the brackets are not strictly required ... but i would even recommend that they are always used since you just have to add them when you want to extend the code later on ... and even use the semicolon to terminate the statements ... its good practice to do so, even when they are not strictly required too :)
kind regards
unless there is just one, and only one, statement, the brackets are not strictly required ... but i would even recommend that they are always used since you just have to add them when you want to extend the code later on ... and even use the semicolon to terminate the statements ... its good practice to do so, even when they are not strictly required too :)
kind regards
touchè.
thanks, its been a couple months since i learned something new about javascript.
also gave me another optimization for my code compressor.
gits 5,390
Expert Mod 4TB
so do you want to 'compress-remove' the brackets, for deployment-versions? quite a nice idea, and certainly worth a look at ... since a lot of brackets and whitespaces could be left out for getting a working script, but its not well readable then ;)
kind regards
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Andy Fish |
last post by:
Hi,
I want to use an anchor tag to invoke some javascript and I've read that
it's bad form to use <a href="javascript:foo()">
I've read endless usenet posts and hint sites on the net, they all...
|
by: GIMME |
last post by:
Background ...
I've created a web application that allows a user to create an
HTML application from IE.
The application itself creates an XML representation of a XHTML
form. The XHTML...
|
by: elsenraat_76 |
last post by:
Hello! I was wondering if someone could help me out with a problem I'm
having? I'm trying to input a javascript value into an anchor tag
(from a function), but don't have an event to call the...
|
by: Matt Kruse |
last post by:
http://www.JavascriptToolbox.com/bestpractices/
I started writing this up as a guide for some people who were looking for
general tips on how to do things the 'right way' with Javascript. Their...
|
by: Steven |
last post by:
Hello,
I have 3 files --
1. mainform.aspx
2. mainform.aspx.cs
3. mouse.js
mainform.aspx contains a image button ("zoominimgbut") which will exceute C#
code, whenever the user clicks on it....
|
by: useenmelately |
last post by:
Hello,
I am working with asp.net 2.0 and have run into a problem with the
custom validators.
The client validation functions were originally written in vbscript,
but as this is not compatible...
|
by: Frank |
last post by:
Hi,
I am working with VS.NET 2005
Ultimately, I wish to call a JavaScript function from a .js file
|
by: lorlarz |
last post by:
Crockford's JavaScript, The Good Parts (a book review).
This shall perhaps be the world's shortest book review (for one of the
world's
shortests books).
I like Douglas Crockford (because I am a...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |