How to use JAlerts - javascript

Hi I am new to jQuery. Can some body tell me how to use JAlert in a project. Please help. thnx
ps
Hi I have used it in a netbeans project. But it doesnot work
<html>
<head>
<script type="text/javascript" src="jquery.js" ></script>
<script type="text/javascript" src="jquery.jalert.js" ></script>
<link href="jalert.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<script>
function hello()
{
jAlert('Price should be blocks of 10 cents', 'FAILED', );
}
</script>
</head>
<body>
<form name="accounts" method="POST" action="test.jsp">
<input type="button" name="clientAccount" value="click" onclick=hello()>
</form>
</body>
</html>
can sombody tell me what the problem

Go to the jAlert demo page and view the source code.

see http://www.smooka.com/blog/2009/02/22/jalert-jquery-alert-box-plugin/
But please first search for jalert in Google, if you can't find something, you can ask a question here.

Related

JQuery twentytwenty Plugin

Pretty new to coding, can't get this plugin working. I know this will be a quick fix for more experienced peeps, but for me, it's driving me insane...
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="event.move.jquery.json"></script>
<link rel="stylesheet" type="text/css" href="foundation.css">
<script src="jquery-3.0.0.min.js"></script>
<script src="jquery.event.move.js"></script>
<script src="jquery.twentytwenty.js"></script>
<link rel="stylesheet" type="text/css" href="twentytwenty.css">
<script>
$(window).load(function() {
$("#container1").twentytwenty();
});
</script>
<title>test</title>
</head>
<body>
<div id="container1" class="twentytwenty-container">
<img src="images/IMG001.jpg">
<img src="images/IMG001_alt.jpg">
</div>
</body>
</html>
I've downloaded and pasted the JS files exactly as they came online. The instructions at the plugin source page make it sound so simple, but I ain't got a clue what I'm doing wrong... All I have done is change the images. Any guidance would be much appreciated :)
Plugin Source: http://zurb.com/playground/twentytwenty
Use jquery 1.10.1 instead of 3.
Try commenting this line and try again
<script src="event.move.jquery.json"></script>

FancyBox Implementation Problems

I'm having some problems getting FancyBox to work...I figure its something pretty simple but I'm still a beginner with web design and the process is a little confusing to me right now. This is what I have so far:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<!-- ******************* CSS ******************* -->
<link rel="stylesheet" href="/fancybox/jquery.fancybox.css" type="text/css" media="screen" />
<!-- ******************* Javascript ******************* -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" src="./fancybox/jquery.fancybox.pack-1.3.4.js"></script>
<script type="text/javascript" src="./fancybox/jquery.fancybox.pack-1.3.4.pack.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("a.iframe").fancybox();
});
</script>
</head>
<body>
<a class="iframe" href="./iFrameFancy.html">Test FancyBox Here!</a>
</body>
The error I'm getting is pretty popular on SO but I've looked for all the fixes mentioned and nothing has worked yet. This is what I'm getting:
Uncaught TypeError: Object #<Object> has no method 'fancybox'
Any help with this would be greatly appreciated! Thanks all!
You are loading fancybox twice (the normal source one and the packed one). Also remove the dot from your src attributes and make sure the file is where you say it is
So change this
<script type="text/javascript" src="./fancybox/jquery.fancybox.pack-1.3.4.js"></script>
<script type="text/javascript" src="./fancybox/jquery.fancybox.pack-1.3.4.pack.js"></script>
To this
<script type="text/javascript" src="/fancybox/jquery.fancybox.pack-1.3.4.js"></script>
or only this
<script type="text/javascript" src="/fancybox/jquery.fancybox.pack-1.3.4.pack.js"></script>
but not both
Try not including the fancybox js file twice on the same page.

Uncaught ReferenceError: (function) is not defined

I just think this is useful for people having this problem:
I had this code:
<html>
<head>
<link rel="stylesheet" href="example.css" type="text/css"/>
<title>CSS TESTS</title>
<script language="text/javascript">
var move = 0;
</script>
</head>
<body>
<input type="text" id="shape" onchange="alert(move);"/>
</body>
</html>
But I couldn't get the alert to work. I would get the Uncaught ReferenceError: move is not defined.
It turns out that the language attribute on the script tag did not allow me to specify text/javascript but only javascript. The type attribute allows "text/javascript". That was all and I spent hours trying to find the bug in the javascript code... arg!
So, basically I changed the line that said
<script language="text/javascript">
to
<script type="text/javascript">
and it all worked.
Change <script language="text/javascript"> TO <script type="text/javascript">
Working Code --
<html>
<head>
<link rel="stylesheet" href="example.css" type="text/css"/>
<title>CSS TESTS</title>
<script type="text/javascript">
var move = 0;
</script>
</head>
<body>
<input type="text" id="shape" onchange="alert(move);"/>
</body>
</html>
or do this, here "move" casted as string
<html>
<head>
<link rel="stylesheet" href="example.css" type="text/css"/>
<title>CSS TESTS</title>
</head>
<body>
<input type="text" id="shape" onchange="alert('move');"/>
</body>
</html>
Dont forget to include ,
<script src="jquery-1.xx.x.min.js" type="text/javascript"> </script>
if you are using jquery, xx-x stand for the version you are using.

dynamic javascript date picker

I have a script for dynamic javascript date picker, taken from here. Please scroll down to Toggle by Element which i want to implement but it is not working
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<SCRIPT type="text/javascript" src="js/jquery.min.js"></SCRIPT>
edit: i added the following mootools script
<script src='http://cdnjs.cloudflare.com/ajax/libs/mootools/1.3.2/mootools-yui-
compressed.js'
type='text/javascript'></script>
<SCRIPT type="text/javascript" src="datepicker.js"></SCRIPT>
<SCRIPT type="text/css" src="datepicker.css"></SCRIPT>
<SCRIPT type="text/css" src="datepicker_vista.css"></SCRIPT>
</head>
<body>
<script language="JavaScript">
window.addEvent('load', function() {
new DatePicker('.demo_allow_empty', {
pickerClass: 'datepicker_dashboard',
allowEmpty: true
});
});
</script>
<label>Datepicker starting at and allowing no value:</label>
<input name='date_allow_empty' type='text' value='' class='date demo_allow_empty' />
</body>
</html>
what i am missing?
It seems it require mootools, i cant see any mootools script tag in your source.
it has nothing to do with jQuery.
edit : here is an exemple :
<script src='http://cdnjs.cloudflare.com/ajax/libs/mootools/1.3.2/mootools-yui-compressed.js'
type='text/javascript'></script>
put it before the date picker script

alex gorbatchev's syntax highlighter not working for me

I'm just posting my entire page to prevent confusion. I've stared at each link and checked the folder for the files. it all seems to be there. what's not working? very frustrated, could use a fresh pair of eyes. all my page displays is the content of the pre, but without any formatting. again, thanks for the help
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--STYLESHEET LINKS-->
<link href="stylesheet.css" rel="stylesheet" type="text/css" media="screen" />
<link href="shThemeDefault.css" rel="stylesheet" type="text/css" media="screen" />
<link href="shCore.css" rel="stylesheet" type="text/css" media="screen" />
<!--SYNTAX HIGHLIGHTER-->
<script type="text/javascript" src="shCore.js"></script>
<script type="text/javascript" src="shBrushPhp.js"></script>
<!--JQUERY and PROCESSING SCRIPTS-->
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery-ui.js"></script>
<script type="text/javascript" src="processing.js"></script>
<script type="text/javascript" src="init.js"></script>
</head>
<body>
<pre class="brush: php">
$last_modified = filemtime("header.php");
echo("last modified: ");
echo(date("m.j.y h:ia", $last_modified));
</pre>
<script type="text/javascript">
SyntaxHighlighter.HighlightAll();
</script>
</body>
</html>
Four things:
SYNTAX HIGHLIGHTER - put the .js files AFTER the jquery, jQueryUI, etc. scripts. The order is important!
use $(document).ready to make sure that all the js files are loaded before the body content tries to use it.
Are you using firebug or some such tool to check for script errors in the browser?
Are you getting any errors at all or just not seeing the highlighting effect?
By replacing:
SyntaxHighlighter.HighlightAll();
with
SyntaxHighlighter.all();
your sample code works for me.

Categories