
Donald asks…
Problem with javascript?
Right now I’m trying to construct a live search engine which is connected to the SQL database. I’ve managed all like fetching data and displaying it etc. It is a live search bar, which fetches data from the database and displays it, as soon as you type something in it. The only problem is that when I erase my input in the search bar, i see the whole database. So to prevent that, i wrote a jscript code:
The code fetches data from the database and puts it in a div called “results”. Here:
<script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js”>
var myLength = $(“#searchbar”).val().length;
if (myLength ===0)
{
function barCleaner(value) {
document.getElementById(“results”).value=’nothing to see’;
}
}
else {
function getStates(value) {
$.post(“getStates.php”, {partialState:value},function(data) {
$(“#results”).html(data);
}) ;
}
}
The aim of this code is to say “nothing to see” if the search bar is empty and else, fetch the data from the database. The problem is with the “nothing to see” part. Well, that’s it. Thanks in advance

Administrator answers:
Next time I would suggest that you include the phrase jQuery in your next questions, you will get a better response. Your question has bits cut off, be aware of that in the future. You’re also mixing techniques…
Your problem arises from the fact that you declare the function if the myLength is zero, but you never call it.
function barCleaner() {
$(“#results”).html( ‘Nothing to see’ );
// Or whatever styling/html you want.
}
function getStates(value) {
$.post(“getStates.php”, {partialState:value},function(data) {
$(“#results”).html(data);
});
}
function liveSuggest(){
var myLength = $(“#searchbar”).val().length;
if(myLength > 0){
getStates( $(‘#searchbar’).val() );
}else{
barCleaner();
}
Redeclaring the functions every time is a bit of a waste of resources.
Cheers,
Gitlez

Mary asks…
Would this be a good header for my HTML page?
<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js”>

Administrator answers:
Yup, it is all good. Try to keep those on every page.
Good Luck!
If you need further assistance/advice, feel free to contact me.

Laura asks…
Resize HTML body on windows resize?
I have the following code but it does not work:
<script src=”//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js” type=”text/javascript”>
$(window).resize(function(){
$(‘body’).css({‘height’:($(window).height())+’px’});
});
Any ideas

Administrator answers:
JS only works for those browsers that have it enabled.
Choosing Dimensions for Your Web Page Layout:
In Search of the Holy Grail: http://www.alistapart.com/articles/holygrail/
http://www.elated.com/articles/choosing-dimensions-for-your-web-page-layout/
How to create flexible sites quickly using standards like CSS and XHTML: http://www.ibm.com/developerworks/web/library/wa-rapid/
Care With Font Size: http://www.w3.org/QA/Tips/font-size
Websites Shouldn’t Look The Same Across Different Browsers: http://www.noupe.com/design/websites-shouldnt-look-the-same-across-different-browsers%E2%80%A6here-is-why.html
Cross-Browser CSS in Seconds with Prefixr: http://net.tutsplus.com/articles/news/cross-browser-css-in-seconds-with-prefixr/
It’s Not Responsive Web Building, It’s Responsive Web Design: http://www.getfinch.com/finch/entry/its-not-responsive-web-building-its-responsive-web-design/
Beginner’s Guide to Responsive Web Design: http://thinkvitamin.com/design/beginners-guide-to-responsive-web-design/
Ron

Steven asks…
Internet Explorer 7 Error “Expected identifier, string or number. Line: 10, Char: 5″?
I have a javascript gallery here and it displays perfectly in safari and firefox and Chrome. However, when I run it in IE 7, it gives me this error: “Expected identifier, string or number. Line: 10, Char: 5″. I read around and learned that this may de due to a misplaced or unnecessary comma, but i just can’t seem to find the problem. I have to finish this for a client, please help. Thanks in advance! =D
<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js”>
html,body{background:#FFFFFF} #galleria{width:900px;margin:20px auto}

Kennett Symphony Holiday

Liz Marden Gourmet Cakes and Desserts Ad

Liz Marden Gourmet Cakes and Desserts Ad

Kennett Symphony Orchestra Holiday Ad

Martin Luther King Community Breakfast

Kennett Symphony Orchestra

Kennett Symphony Orchestra|Music and More in 2010

Kennet Symphony Orchestra Holiday

Liz Marden Country Club Ad

Melton Architects Christmas Card

Church of the Open Door|Celebrate the Season
<?php
$dir = “./otheradsposters”;
//open dir
if ($opendir = opendir($dir))
{
//read dir
while (($file = readdir($opendir)) !==FALSE)
{
if ($file!=”.”&&$file!=”..”&&$file!=”.DS_Store”)
echo ““;
}
}
?>
// Load theme
Galleria.loadTheme(‘./donnatheme.js’)
// run galleria and add some options
$(‘#galleria’).galleria({
image_crop: false,
transition: ‘fade’,
data_config: function(img) {
return {
description: $(img).next(‘p’).html()
}
}
})

Administrator answers:
I would guess the error is in the script. Can we see the live page?

Robert asks…
How can i learn all these..GOD?
Is it complusory that we need to learn all there for web designing,
Graphic designing, HTML, HTML5, CSS, DHTML, PHP, JSP, SQL, XML, XHTML, AJAX JavaScript, jquery Actionscript VBScript, Dream weaver, Photoshop, Fireworks, Flash with action script knowlege, CMS (web content management system).
Why do we need VBScript when we have JavaScript?
Why do we need ASP/ASP.Net when we have PHP?

Administrator answers:
For web designing, no. Designing is artwork. If you’re doing design you need graphic designing, Photoshop (or equivalent – professionals tend to not use Adobe) and Fireworks.
For development? HTML5, not yet, but you’ll be using at least parts of 5 soon. (We’re using 4 now.)
DHTML? Not really, but it’s not very much to learn.
JSP? You don’t need Java-anything to develop websites.
SQL? If you’re going to talk to databases, that’s the only way.
XML and XHTML? Not really.
AJAX? No, but you should. Once you learn how to do it (it’s just a technique), you’ll just be copying code from page to page. And it makes a MUCH nicer working site.
Javascript, yes. Period.
The rest? Not really.
VBScript and ASP are for Windows servers that don’t have PHP installed. I just refuse to use them, so I don’t worry about Microcrap. (I know VBScript and ASP, I just choose to not write for toy servers.)
Powered by Yahoo! Answers
|
