ELATED: Authoring and Programming http://www.elated.com/ The nitty-gritty of coding websites. Get help with HTML, CSS, JavaScript, PHP, Perl, or any other Web programming problem. en-us Sun, 12 Feb 2012 14:27:24 GMT Sun, 12 Feb 2012 14:27:24 GMT http://blogs.law.harvard.edu/tech/rss ELATED.com feeder Re: Mouseover sequence http://www.elated.com/forums/topic/5410/#post22310 From: Denn


Solved it, thanks anyway.

View » | Reply »

]]>
Sun, 12 Feb 2012 12:50:19 GMT http://www.elated.com/forums/topic/5410#post22310
Mouseover sequence http://www.elated.com/forums/topic/5410/#post22309 From: Denn


Hi there.

I'm trying to make a little valentines website 'card' for my ladyfriend. I was going to be clever about it and use javascript, but as it turns out I'm really not that clever with it anymore. I need a single image to change into a different image on each following mouseover event. A planned 'route' of images, for exameple A -> B -> C -> D -> E -> A -> F - > B -> .. and so on.

I thought I could do this, but I'm getting nowhere. I did try to look for similar attempts to make this, but it's kind of hard to find since 'mouseover' is such a generic search term.

There's little point for me in posting my code so far.. it's just a long list of imagecodes and a little mouseover script that would probably make you laugh.

Thanks.

View » | Reply »

]]>
Sun, 12 Feb 2012 12:21:31 GMT http://www.elated.com/forums/topic/5410#post22309
Re: Build a CMS in an Afternoon with PHP and MySQL http://www.elated.com/forums/topic/5114/#post22308 From: BlackhawkNZL


Ok, so I think I found out what my problem is. I didn't have PDO enabled in my local php.ini. This isn't a problem, however - when I uploaded the project to my web host - they also did not have PDO enabled; when questioned if they could enable it for me, they advised that they were not able to due to due to other clients using Curl with SSL support.

So, my new question is this: what can I use in place of PDO? Would a basic DB class suffice? (Obviously losing some of the security that PDO gave). If so, how would that be implemented?

View » | Reply »

]]>
Sun, 12 Feb 2012 00:28:44 GMT http://www.elated.com/forums/topic/5114#post22308
Re: Build a CMS in an Afternoon with PHP and MySQL http://www.elated.com/forums/topic/5114/#post22306 From: oxygen


@Matt

I found this webpage/post by accident and I am so glad I did. I have been a coding basic websites and apps for years, but I have always been worried about the security of my code (its pretty unsecure!).

I am going to re-write a few things around this model. I would love to see more tutorials like this one. I took the time to understand how it all works, rather than just download the zip files.

Thanks for this tutorial - I look forward to hitting the forums with any questions I may have!

View » | Reply »

]]>
Sat, 11 Feb 2012 11:42:01 GMT http://www.elated.com/forums/topic/5114#post22306
Re: Build a CMS in an Afternoon with PHP and MySQL http://www.elated.com/forums/topic/5114/#post22305 From: BlackhawkNZL


G'day Matt.

Absolutely brilliant tutorial on the CMS. It has helped bucketloads in a current project and has allowed me to completely avoid having to use Wordpress, Drupal etc.

I am experiencing a problem however. I can add an article, the id, summary and content are stored sucessfully in the DB. However, when I log in as admin, I get a "Notice: Trying to get property of non-object" error that seems to stem from the "editArticle.php" script.

I haven't edited your code in any way, however - it seems that the article object either hasn't been created (which I don't think is the case, as the data is correctly sent to the DB), or there is a block somehwere in accessing the object.

The error repeats on each input line of the form (id, title, summary, content and date) and in the relevant fields where one should be editing, it is spitting out the error tables in HTML format.

I am completely confuzzled, any help would be greatly appreciated.


Any help would be greatly appreciated!

View » | Reply »

]]>
Sat, 11 Feb 2012 03:56:31 GMT http://www.elated.com/forums/topic/5114#post22305
Re: How to Make a Slick Ajax Contact Form with jQuery and PHP http://www.elated.com/forums/topic/5171/#post22303 From: 68bydesign


Hey,

first thanks for this great script!

I added an extra field for a telephone number and a checkbox where the user can request to be called back.

Is there any possibilty for set the telephone-field to "required" when the checkbox is checked?

thanks for you help.

View » | Reply »

]]>
Fri, 10 Feb 2012 11:03:30 GMT http://www.elated.com/forums/topic/5171#post22303
Background image not scrolling in IE7 & 8 http://www.elated.com/forums/topic/5408/#post22302 From: sokogs


I'm having problems with the second background image behind the content not scrolling as it should in IE7 & 8. All is working fine in PC Firefox, Chrome, IE9, Mac Firefox, Safari, Chrome. In IE 7 & 8 the image that should be scrolling is sitting up by the top navigation bar, showing where it shouldn't.

Can someone please advise me how to fix this? Further complications are multiple background images, the drop shadow and rounded corner effects.

Here are the links to the site and the css:

http://www.susankurtzgraphics.com/OGS/A_PresentationPanel_Template.html

http://www.susankurtzgraphics.com/OGS/css/styles1.css

[Edited by sokogs on 09-Feb-12 16:01]

--
sokogs

View » | Reply »

]]>
Thu, 09 Feb 2012 21:07:08 GMT http://www.elated.com/forums/topic/5408#post22302
Re: Build a CMS in an Afternoon with PHP and MySQL http://www.elated.com/forums/topic/5114/#post22301 From: DOC


I wonder should I give that pagination code a try....or wait for Matt's approval It's pretty much the only thing keeping from putting my site live.

View » | Reply »

]]>
Thu, 09 Feb 2012 18:13:53 GMT http://www.elated.com/forums/topic/5114#post22301
Re: Build a CMS in an Afternoon with PHP and MySQL http://www.elated.com/forums/topic/5114/#post22300 From: chotikarn


@jj if you would like to add pagination, try this...

first make new function in Class


Code:
--------------------
public static function getPaginate( $order="publicationDate DESC" ) {

$per_page = 7; //set item per page

$conn = new PDO( DB_DSN, DB_USERNAME, DB_PASSWORD, array (PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8") );
$sql = "SELECT * FROM articles";
$query = $conn->query( $sql )->fetchAll();
$Num_Rows = count($query);

if(empty($_GET['page']) ){
$_GET['p'] = "";
}
$p= $_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;
}

$query = "SELECT SQL_CALC_FOUND_ROWS *, UNIX_TIMESTAMP(publicationDate) AS publicationDate FROM articles
ORDER BY " . mysql_escape_string($order) . " LIMIT $Page_Start, $per_page";
$result = $conn->prepare($query);
$result->execute();
$list = array();

while ($row = $result->fetch() ) {
$article = new Articles( $row );
$list[] = $article;
}

$conn = null;
return ( array ( "results" => $list, "Num_Rows" =>$Num_Rows, "Num_Pages" => $Num_Pages, "page" => $page, "Prev_Page" => $Prev_Page, "Next_Page" => $Next_Page ) );
}
--------------------

and then modify our index.php to handle pagination function
i'm need to use it only in archive page, so here is it.


Code:
--------------------
function archive() {

$results = array();
$data = Articles::getPaginate(); // call paging function instead of getById.
$results['articles'] = $data['results'];
$results['Num_Rows'] = $data['Num_Rows'];
$results['Num_Pages'] = $data['Num_Pages'];
$results['Prev_Page'] = $data['Prev_Page'];
$results['Next_Page'] = $data['Next_Page'];
$results['page'] = $data['page'];
$results['pageTitle'] = "Article Archive";
require( TEMPLATE_PATH . "/archive.php" );
}
--------------------

then on the archive page we will render our pagination
just put it on top of archive list of bottom.


Code:
--------------------
<div id="paginav">
<?php
$Current_Page = $_SERVER['SCRIPT_NAME'];
$Prev_Page =$results['Prev_Page'];
$Next_Page =$results['Next_Page'];
$Num_Pages =$results['Num_Pages'];
$page =$results['page'];
if($Prev_Page)
{
echo "<a href = '$Current_Page?action=archive&p=$Prev_Page'><< Previous</a>";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i !=$page)
{
echo "<a href ='$Current_Page?action=archive&page=$i'>$i</a>";
} else {
echo "<span>$i</span>";
}
}
if($p != $Num_Pages)
{
echo "<a href ='$Current_Page?action=archive&page=$Next_Page'>Next>></a>";
}
?>
</div>
--------------------


it's not look smooth enough but maybe helpful, and i'm newbie to PHP like you, cheer!.

Note, i have modified original code. maybe have conflict with original code, then let's me know, if it have any error.

[Edited by chotikarn on 09-Feb-12 11:42]

View » | Reply »

]]>
Thu, 09 Feb 2012 17:36:26 GMT http://www.elated.com/forums/topic/5114#post22300
Re: Build a CMS in an Afternoon with PHP and MySQL http://www.elated.com/forums/topic/5114/#post22299 From: jj


This article was amazing! Thank you Matt for your superb work.
Well written and good to learn from!
I'm kind of new to this whole php-thing, but I'm learning from every tutorial

I have, at this date, included a whole custom CSS, the CKEditor and KCFinder to this work, just to play with, and it works great (after several face-palms and whatnots)!

For thos who are interested, a sample: Guolldo dot com/cms/admin dot php

Now, my next task is to integrate a pagination, and here is where I'm stuck. I have tried to search the web for a good tutorial that I can combine whit the whole cms, but every tut I read ends up with me looking like a question mark.

So..
Can somebody maybe point me in the right direction for some good documentation?

Or, Matt. Have you taught about maybe write a follow-up article with pagination? I think there are many of us that would be able to learn allot more, and discover new possibilities whit one more good tutorial

Thanks allot again, and I apologize for my spelling and grammar.. / J

View » | Reply »

]]>
Thu, 09 Feb 2012 15:48:48 GMT http://www.elated.com/forums/topic/5114#post22299
Re: Using Javascript's Location Object to Work with URLs http://www.elated.com/forums/topic/4705/#post22298 From: valestudios


Hi, thanks for the article. Is there any way to essentially combine the replace and reload functions? I need to force the page to reload and land on a specific anchor tag.

View » | Reply »

]]>
Thu, 09 Feb 2012 02:52:43 GMT http://www.elated.com/forums/topic/4705#post22298
Re: Print Button? http://www.elated.com/forums/topic/5405/#post22297 From: lmw1


No luck there, that's why I cam here.

Can't do this with Javascript?

I thought for sure you'd know how to pull this one off.

Oh well. Thanks anyway. I appreciate you replying.

Respectfully,
LMW1

View » | Reply »

]]>
Wed, 08 Feb 2012 22:19:54 GMT http://www.elated.com/forums/topic/5405#post22297
jquery + css image gallery help http://www.elated.com/forums/topic/5407/#post22296 From: cambridge7


Hi,
Am trying to get away from flash + new to jquery.
I know there is an obvious problem in the Css or js but the more I change things around the worse it gets. I want the gallery up next to the right of the nav column. Sick of pulling hair........
http://www.andy.taupedesign.com/gallerytest.html

thanks

View » | Reply »

]]>
Wed, 08 Feb 2012 19:23:10 GMT http://www.elated.com/forums/topic/5407#post22296
Re: JavaScript Timers with setTimeout and setInterval http://www.elated.com/forums/topic/4682/#post22295 From: froopy


Thank you for this post.
I was able to modify this for a music writing application.
I will link back.

View » | Reply »

]]>
Wed, 08 Feb 2012 14:16:57 GMT http://www.elated.com/forums/topic/4682#post22295
Re: JQuery Mobile - Appling 'Loading' to image hyperlinks http://www.elated.com/forums/topic/5401/#post22294 From: markaspirenet


I just went back and double checked.

Here's the situation

The initial page that has the banner on it which inside the IFRAME. If I take out the target="cb" (Same frame as where the banner is placed, the IFRAME it sits inside is also called CB, so basically stay inside that window, it will show a jquery error of ERROR LOADING PAGE when the banner is clicked on because the page that it goes to has a CFLOCATION URL="" Coldfusion redirect on there that tells the client to go redirect.

If I put in the target="cb" then it all works fine, but I lose the LOADING

I tried removing the CFLOCATION and using a simple Meta Refresh set to 0, but nothing at all happens no redirect.

I then took out the redirect and put in some jquery code, and it displays fine

So basically what I have is a situation where, if I have a redirect on the page the hyperlink goes to, and it is in a frame, even as in this case it is staying inside the same frame then it will throw a Jquery error loading page unless I name the frame and add the target

That really sucks

Any ideas if there is any potential for work arounds for this?

Thanks

Mark

View » | Reply »

]]>
Wed, 08 Feb 2012 06:44:33 GMT http://www.elated.com/forums/topic/5401#post22294
Re: JQuery Mobile - Appling 'Loading' to image hyperlinks http://www.elated.com/forums/topic/5401/#post22293 From: markaspirenet


Hi Matt

Thanks for the reply. I am sure you are right, but just to clarify the situation.

I have a page, popup.cfm a coldfusion page, inside popup.cfm is a little HTML to display some Jquery Mobile, namely a button at the top, and also an IFRAME.

Inside the IFRAME is a link to popup_center.cfm which displays a banner, the code for the IFRAME also includes NAME="CB"

The page popup_center.cfm has Juqery code inside it, headers etc,etc. The banner inside this frame has a link to the 3rd party web site, as a simple A HREF.

Now the problem I had was that if I did not have the target="cb" the same name as the frame that it was already in, the code would not work, it was screwing up, I spent a day or more figuring this out, although I would need to test again as I can't remember the problem I had as I've been in debug mode for a solid 14 days and nights.

So because I refer it to the same window, just because of the reference to a target the LOADING is not going to work?

I am going to remove that target so I can remind myself what the problem was, but I don't believe it will function without it

Any idea if there is any way around this?

Thanks

Mark

View » | Reply »

]]>
Wed, 08 Feb 2012 06:17:18 GMT http://www.elated.com/forums/topic/5401#post22293
Re: How to Make a Slick Ajax Contact Form with jQuery and PHP http://www.elated.com/forums/topic/5171/#post22291 From: matt


@apokyro: Try just adding the 'u' flag to the calls to preg_replace(), as I describe here:

http://www.elated.com/forums/topic/5171/#post20818

Also make sure the HTML document containing the form uses UTF-8 encoding:


Code:
--------------------
<meta charset="utf-8">
--------------------


--
Matt Doyle, Elated
Second Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/


View » | Reply »

]]>
Wed, 08 Feb 2012 05:33:15 GMT http://www.elated.com/forums/topic/5171#post22291
Re: jQuery Mobile Form Validation http://www.elated.com/forums/topic/5397/#post22290 From: matt


Hi Andrew,

Hmm, in that case try binding to pagebeforeshow or pageshow instead:


Code:
--------------------
$('#myPage').live( 'pageshow', function() {
...
} );
--------------------


These events fire each time the page is displayed (p220 in the book).

--
Matt Doyle, Elated
Second Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/


View » | Reply »

]]>
Wed, 08 Feb 2012 05:26:52 GMT http://www.elated.com/forums/topic/5397#post22290
Re: Print Button? http://www.elated.com/forums/topic/5405/#post22289 From: matt


@lmw1: I know next to nothing about Joomla I'm afraid! Maybe try http://forum.joomla.org/ ?

--
Matt Doyle, Elated
Second Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/


View » | Reply »

]]>
Wed, 08 Feb 2012 05:24:00 GMT http://www.elated.com/forums/topic/5405#post22289
Re: Syntax error http://www.elated.com/forums/topic/5404/#post22288 From: matt


@eman: You didn't close your top block of PHP code. Try this:


Code:
--------------------
...
$gtr_shop1_products=$db->query($query); // $gtr_shop1_products contains the result set

?>

<?php foreach ($gtr_shop1_product as $gtr_shop1_product) { ?>
...
--------------------


--
Matt Doyle, Elated
Second Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/


View » | Reply »

]]>
Wed, 08 Feb 2012 05:22:18 GMT http://www.elated.com/forums/topic/5404#post22288
Re: Create Your Own Blogger Template http://www.elated.com/forums/topic/4825/#post22285 From: matt


@cleverfox: Great stuff

--
Matt Doyle, Elated
Second Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/


View » | Reply »

]]>
Wed, 08 Feb 2012 05:09:38 GMT http://www.elated.com/forums/topic/4825#post22285
Re: JQuery Mobile - Appling 'Loading' to image hyperlinks http://www.elated.com/forums/topic/5401/#post22284 From: matt


Hi Mark,

Using the target attribute prevents jQuery Mobile from handling the link via Ajax, since you can't load a page via Ajax into a separate window or frame.

From p193 in my book:

---
You can also turn off Ajax handling for specific links and forms by using the data- ajax="false" attribute. See Appendix B for details. Adding the attribute rel="external" to a link, or using the target attribute, will also disable Ajax handling for the link.
---

Since the "Loading" message is part of jQM's Ajax loading process, you won't see the message if you use the target attribute.

--
Matt Doyle, Elated
Second Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/


View » | Reply »

]]>
Wed, 08 Feb 2012 05:08:22 GMT http://www.elated.com/forums/topic/5401#post22284
Re: How to Make a Slick Ajax Contact Form with jQuery and PHP http://www.elated.com/forums/topic/5171/#post22283 From: matt


@kimbo6365: Great tip - thanks for posting

@Sventovit: Hmm, not sure. I'd have to see your whole PHP script. I assume you are calling session_start() in the script for some reason?

My guess is that, since your PHP script works on one page and not another, there's a problem in the second page (either in the form JavaScript, the markup, or some other conflicting JavaScript) that is preventing the data getting to the PHP script.

--
Matt Doyle, Elated
Second Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/


View » | Reply »

]]>
Wed, 08 Feb 2012 05:02:43 GMT http://www.elated.com/forums/topic/5171#post22283
Re: How to Make a Slick Ajax Contact Form with jQuery and PHP http://www.elated.com/forums/topic/5171/#post22282 From: apokyro


Matt this is an awesome tutorial and i think you done great job!! I tested the form and it works like a charm.

One thing I want, if you can help me! I'm trying to fill the form with greek characters and the message appears weird. I scroll the messages and i saw that maruse also had the same issue with Japanese and he solve it! Unfortunately I don't know how to use the strip_tag(). If you can post a solution about, I will appreciate a lot!
Also, is it possible to write at fields John Smith and Visitor Message something in different language and appears correct??

Thank you!!

View » | Reply »

]]>
Mon, 06 Feb 2012 18:00:22 GMT http://www.elated.com/forums/topic/5171#post22282
Re: How to Make a Slick Ajax Contact Form with jQuery and PHP http://www.elated.com/forums/topic/5171/#post22279 From: Sventovit


Hello Matt
thanks again for the support.
I’ve tried this weekend to "debug" and only found this error when trying to send a mail using the form on a single article page:
A session had already been started - ignoring session_start()
Hum…

View » | Reply »

]]>
Mon, 06 Feb 2012 09:28:32 GMT http://www.elated.com/forums/topic/5171#post22279
Re: jQuery Mobile Form Validation http://www.elated.com/forums/topic/5397/#post22278 From: databuzz


Thanks Matt,

Sorry I didn't see that in the book. It's working now, however only the first time.

If I enter an incorrect username/password it returns the login.php page again with an error at the top, however this time it doesn't alert me if I attempt to login without entering a username/password.

Any ideas why it's only working on the first page load?

thanks,
Andrew

View » | Reply »

]]>
Mon, 06 Feb 2012 02:19:42 GMT http://www.elated.com/forums/topic/5397#post22278
Re: dates not properly exchanged between PHP and MySQL http://www.elated.com/forums/topic/5385/#post22277 From: shelley3


Thanks, Matt. I'll do that.

shelley

--
What will we do when the power goes out?

View » | Reply »

]]>
Sun, 05 Feb 2012 19:41:40 GMT http://www.elated.com/forums/topic/5385#post22277
Re: Events and Event Handlers http://www.elated.com/forums/topic/4630/#post22276 From: kalyan


Replacement for alert event

View » | Reply »

]]>
Sun, 05 Feb 2012 17:20:02 GMT http://www.elated.com/forums/topic/4630#post22276
Password Protected Menu Item? http://www.elated.com/forums/topic/5406/#post22273 From: lmw1


My 2nd question related to Joomla CMS.

My client wants a main menu item password protected in order for users to see the contents/sub-menu items/articles associated with that main menu item.

How can this be accomplished in Joomla CMS?

Respectfully,
LMW1

View » | Reply »

]]>
Sun, 05 Feb 2012 00:54:27 GMT http://www.elated.com/forums/topic/5406#post22273
Print Button? http://www.elated.com/forums/topic/5405/#post22272 From: lmw1


I have a Joomla 2.5 website. In one of my articles I have a table (form) and I want users to be able to click a "print button" to print out the form on their printer.

Joomla has a print button at the top right of every article, but when you use it, it prints the entire article.

I just want the "form in the table" to be printed - not the entire article.

Can someone explain how this would be accomplished?

Respectfully,
LMW1

View » | Reply »

]]>
Sun, 05 Feb 2012 00:51:16 GMT http://www.elated.com/forums/topic/5405#post22272
Syntax error http://www.elated.com/forums/topic/5404/#post22270 From: eman


I keep getting this syntax error whenever I run this script below. Can anyone tell me how to correct this? I left the username and password empty for security. Thanks

Parse error: syntax error, unexpected '<' in G:\Inetpub\wwwroot\LocalUser\eijenkins\WEB225\guitar_list.php on line 51

http://198.86.244.3/eijenkins/web225/guitar_list.php

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Product Listing: Guitars</title>
</head>

<body>

<?php

$db_host = "localhost";
$db_username = "x";
$db_pass = "x";

//Make the connection:
@mysqli_connect ("$db_host", "$db_username","$db_pass") OR die ("Could not connect to MySQL");


echo"<h1>Product Listing: Guitars</h1>";

try {
// statements that might throw an exception
} catch (ExceptionClass $exception_name) {
// statements that handle the exception
}

try {
$db = new PDO($dsn, $username, $password);
echo '<p>You are connected to the database!</p>';
} catch (PDOException $e) {
$error_message = $e->getMessage();
echo "<p>An error occurred while connecting to
the database: $error_message </p>";
}

try {
// statements that might throw an exception
} catch (Exception $e) {
$error_message = $e->getMessage ();
echo "<p>Error message: $error_message </p>";
}

$query = 'SELECT productID, productCode, productName, listPrice
FROM gtr_shop1_products
WHERE categoryID = 1';
$gtr_shop1_products=$db->query($query); // $gtr_shop1_products contains the result set


<?php foreach ($gtr_shop1_product as $gtr_shop1_product) { ?>
<tr>
<td><?php echo $gtr_shop1_product['productID']; ?></td>
<td><?php echo $gtr_shop1_product['productCode']; ?></td>
<td><?php echo $gtr_shop1_product['productName']; ?></td>
<td><?php echo $gtr_shop1_product['listPrice']; ?></td>
</tr>
<?php } ?>

View » | Reply »

]]>
Fri, 03 Feb 2012 21:58:30 GMT http://www.elated.com/forums/topic/5404#post22270
Re: Create Your Own Blogger Template http://www.elated.com/forums/topic/4825/#post22267 From: cleverfox


WOW, I made this once again. This time for right-to-left language and everything works smoothly. Thanks!

View » | Reply »

]]>
Fri, 03 Feb 2012 20:35:05 GMT http://www.elated.com/forums/topic/4825#post22267
JQuery Mobile - Appling 'Loading' to image hyperlinks http://www.elated.com/forums/topic/5401/#post22266 From: markaspirenet


If I set up a hyperlink as a button and I click on the link I get the LOADING icon in the middle, which also helps to stop end users for double pressing a link, for example -->

<a href="somelink.html" data-theme="#session.datatheme#" data-role="button" data-icon="back" data-iconpos="left" >Back to somelink</a>

I just noticed that when I hyperlink an IMG that I don't get the LOADING, and this also allowed end users to double click, messing up my stats, so I had to add some extra code to pick this up, I'd really like the LOADING so they know that they have indeed pressed the button.

Is there any code I can put into the code below to make that happen?

<a href="clk.cfm" target="cb">
<img src="images/banners/#GetCamp.camp_uid#.#GetCamp.camp_image_type#" border="0"></a>

I THINK that this might be related to the fact that I have target="cb" in there. I do need this because without the following page will not work, I'm guessing some sort of security rule in javascript because the following page just writes stats and then uses coldfusions cflocation to redirect the user to the banner that they clicked on (the image I served), the page is also inside an Iframe, without the target in the link, I get an error loading page, with it, it works, so no removing that, but could that be causing the missing LOADING? And if so, any way around this??


Thanks

Mark

View » | Reply »

]]>
Fri, 03 Feb 2012 19:23:16 GMT http://www.elated.com/forums/topic/5401#post22266
Re: How to Make a Slick Ajax Contact Form with jQuery and PHP http://www.elated.com/forums/topic/5171/#post22265 From: kimbo6365


Hi Matt!

Thanks for posting this wonderful tutorial!

Because I'm using a form with many more inputs (and for extra security), I prefer to use Tectite's FormMail script for handling the form.

However, one major disadvantage of Tectite's FormMail is that it doesn't support AJAX form submission out of the box. I spent a few hours integrating your JQuery script with Tectite's FormMail and thought I'd share the result for anyone else interested!

I just inserted the AJAX browser response lines before the FormMail script redirects to the Thanks page. In my FormMail.php file, the code to redirect is on line 13482

Code:
--------------------
CreatePage(GetMessage(MSG_THANKS_PAGE),GetMessage(MSG_FORM_OK));
--------------------

With your AJAX browser response code inserted, the code now looks like this:

Code:
--------------------
if ($bGotGoodTemplate){

if ( isset($_GET["ajax"]) ) {
$success = 1;
echo $success ? "success" : "error";
} else {
OutputTemplate($SPECIAL_VALUES["good_template"],$aRawDataValues);
}
}
else {
if ( isset($_GET["ajax"]) ) {
$success = 1;
echo $success ? "success" : "error";
} else {
CreatePage(GetMessage(MSG_THANKS_PAGE),GetMessage(MSG_FORM_OK));
}
}
--------------------


I'm also using my own Thanks page instead of Tectite's auto-generated one, so I inserted the AJAX browser response code before the Thanks Page template is called.

I also used the jQuery serializeArray() method instead of serialize() in order to include hidden inputs from the form, which is crucial to the functionality of FormMail.

It took me a few hours to figure it out, and since I got it working, I thought I'd share with others!

View » | Reply »

]]>
Fri, 03 Feb 2012 16:16:18 GMT http://www.elated.com/forums/topic/5171#post22265
Re: Drag-and-Drop with jQuery: Your Essential Guide http://www.elated.com/forums/topic/5136/#post22264 From: matt


@rgsamways: Off the top of my head...

Try adding the prev/next links, then add click handlers to the links that increase/decrease the margin-left CSS property of the cardPile/cardSlots divs appropriately. Use CSS transitions if you'd like a smooth slide between each position.

Also wrap each div in an outer div with the same dimensions, and apply overflow: hidden to the outer divs. That way the cardPile and cardSlots divs will scroll horizontally within the "window" of the outer div.

--
Matt Doyle, Elated
Second Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/


View » | Reply »

]]>
Fri, 03 Feb 2012 05:16:57 GMT http://www.elated.com/forums/topic/5136#post22264
Re: Javascript problem with a stored variable. http://www.elated.com/forums/topic/5400/#post22263 From: matt


@janix2008: For one thing, you have used the 'var' keyword to create new local variables inside your getUserAnswers() function. These variables will be separate from the global variables at the top of your code. The same goes for "score" inside checkAnswers():


Code:
--------------------
function checkAnswers() {
if (givenAnswerOne == correctOne) {
var score = score + 1;
--------------------


Your line "var score = score + 1" creates a brand new local variable called "score" that is separate from the "score" global variable at the top of your code.

So remove those 'var' keywords, unless you really want to create variables that are local to each function.

--
Matt Doyle, Elated
Second Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/


View » | Reply »

]]>
Fri, 03 Feb 2012 05:08:47 GMT http://www.elated.com/forums/topic/5400#post22263
Re: Problem with linking my web pages http://www.elated.com/forums/topic/5399/#post22262 From: matt


@justyna26: Use a cookie to store the language preference (English or Polish).

If it's just one page then you might get away with using JavaScript in the page to display the page in English or Polish based on the cookie value. However if you have a multi-page site then you'll want to use server-side code such as PHP to read the cookie and serve either English or Polish pages to the user.

Bear in mind that the JavaScript approach won't work for users who have JavaScript disabled in their browsers.

--
Matt Doyle, Elated
Second Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/


View » | Reply »

]]>
Fri, 03 Feb 2012 05:03:22 GMT http://www.elated.com/forums/topic/5399#post22262
Re: dates not properly exchanged between PHP and MySQL http://www.elated.com/forums/topic/5385/#post22261 From: matt


@shelley3: Glad you got it working! Good luck with your next changes. You probably want to limit the articles returned from the database in the call to getList() inside index.php, rather than limiting them in the templates. Similarly, perform the check as to whether to display an article (or not) inside index.php. It's always best to keep functionality out of the template code if possible.

--
Matt Doyle, Elated
Second Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/


View » | Reply »

]]>
Fri, 03 Feb 2012 05:00:14 GMT http://www.elated.com/forums/topic/5385#post22261
Re: How to Make a Slick Ajax Contact Form with jQuery and PHP http://www.elated.com/forums/topic/5171/#post22260 From: matt


@isheets: You need to give more information - what doesn't work exactly? Do you get any error message?

--
Matt Doyle, Elated
Second Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/


View » | Reply »

]]>
Fri, 03 Feb 2012 04:56:41 GMT http://www.elated.com/forums/topic/5171#post22260
Re: MULTIPLE COL LAYOUT http://www.elated.com/forums/topic/5398/#post22259 From: matt


@jorgeco: Tables should work fine, and I recommend using tables if you're displaying tabular data. jQuery Mobile's grids are more designed for laying out page elements.

--
Matt Doyle, Elated
Second Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/


View » | Reply »

]]>
Fri, 03 Feb 2012 04:54:15 GMT http://www.elated.com/forums/topic/5398#post22259
Re: Create Your Own Blogger Template http://www.elated.com/forums/topic/4825/#post22258 From: matt


@Ninj: You can take 2 approaches. If your design is fairly similar to an existing Blogger template, or the Tope example in the tutorial, then you can just tweak the HTML and CSS, testing as you go, until it matches your design. Alternatively, if your design is quite unique, then I would create a static HTML page from the design first. Once you're happy the that the HTML page looks good, insert the Blogger tags into the HTML to turn the page into a Blogger template.

--
Matt Doyle, Elated
Second Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/


View » | Reply »

]]>
Fri, 03 Feb 2012 04:51:34 GMT http://www.elated.com/forums/topic/4825#post22258
Re: jQuery Mobile Form Validation http://www.elated.com/forums/topic/5397/#post22257 From: matt


@databuzz: Thanks for buying my book

Have you tried jQuery Mobile's pageinit event?


Code:
--------------------
$('#myPage').live( 'pageinit', function() {
...
} );
--------------------


This fires just after jQuery Mobile has enhanced the page. It's the jQM equivalent of $(document).ready() (see page 210 in my book).

Cheers,
Matt

--
Matt Doyle, Elated
Second Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/


View » | Reply »

]]>
Fri, 03 Feb 2012 04:46:27 GMT http://www.elated.com/forums/topic/5397#post22257
Re: How to Make an Elegant Sliding Image Gallery with jQuery http://www.elated.com/forums/topic/5158/#post22256 From: matt


If you mean "how can I always show the captions", see my answer earlier in the topic:

http://www.elated.com/forums/topic/5158/#post21591

--
Matt Doyle, Elated
Second Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/


View » | Reply »

]]>
Fri, 03 Feb 2012 04:40:45 GMT http://www.elated.com/forums/topic/5158#post22256
Re: How to Add Article Categories to Your CMS http://www.elated.com/forums/topic/5391/#post22255 From: matt


@hocfictum: "Can you also point me in the right direction if I wanted to create a user(limited) who isn't allowed to add categories?"

If you're sure you're only going to want 2 admin users then you could create a new "user" by hacking config.php:


Code:
--------------------
define( "SUBADMIN_USERNAME", "subadmin" );
define( "SUBADMIN_PASSWORD", "anotherpass" );
--------------------


Then modify login() in admin.php to allow either user to login:


Code:
--------------------
if ( $_POST['username'] == ADMIN_USERNAME && $_POST['password'] == ADMIN_PASSWORD || $_POST['username'] == SUBADMIN_USERNAME && $_POST['password'] == SUBADMIN_PASSWORD ) {

...etc...
--------------------


Then hack the newCategory()/editCategory()/deleteCategory() functions to check that $_SESSION['username'] == ADMIN_USERNAME. If it doesn't, display an error message and exit.

If you think that you might want more admins later, with more fine-grained control, then the "proper" way to do it is to create a new admins table in your database, and store the admin usernames/passwords in there. You'd probably want to create an Admin class too, to handle storing/retrieving administrators, as well as "meta-admin" functions that let you add/edit/delete admins. But that's a fair bit more work.

--
Matt Doyle, Elated
Second Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/


View » | Reply »

]]>
Fri, 03 Feb 2012 04:35:58 GMT http://www.elated.com/forums/topic/5391#post22255
Re: How to Add Article Categories to Your CMS http://www.elated.com/forums/topic/5391/#post22254 From: matt


@mooho058: See:

http://www.elated.com/forums/topic/5114/#post21052
http://www.elated.com/forums/topic/5114/#post21056

You need to adjust your regular expression(s) to include Cyrillic characters.

--
Matt Doyle, Elated
Second Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/


View » | Reply »

]]>
Fri, 03 Feb 2012 04:08:07 GMT http://www.elated.com/forums/topic/5391#post22254
Re: How to Add Article Categories to Your CMS http://www.elated.com/forums/topic/5391/#post22253 From: matt


@hocfictum: Oops, that's a bug in the code.


Code:
--------------------
<option value="0"<?php echo !$category->id ? " selected" : ""?>>(none)</option>
--------------------


It should be:


Code:
--------------------
<option value="0"<?php echo !$results['article']->categoryId ? " selected" : ""?>>(none)</option>
--------------------


I'll fix up the tutorial!

Thanks
Matt

--
Matt Doyle, Elated
Second Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/


View » | Reply »

]]>
Fri, 03 Feb 2012 04:05:07 GMT http://www.elated.com/forums/topic/5391#post22253
Re: CMS in an afternoon: image upload http://www.elated.com/forums/topic/5396/#post22252 From: matt


@iJelle: I posted some hints on image upload here:

http://www.elated.com/forums/topic/5391/

As I say, I may write a follow-up tutorial on image uploading at some point.

--
Matt Doyle, Elated
Second Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/


View » | Reply »

]]>
Fri, 03 Feb 2012 03:54:37 GMT http://www.elated.com/forums/topic/5396#post22252
Re: How to Add Article Categories to Your CMS http://www.elated.com/forums/topic/5391/#post22251 From: chotikarn


@hocfictum

i'm facing same problem like you.

maybe our database does not support foreign key or transaction.

View » | Reply »

]]>
Thu, 02 Feb 2012 20:14:27 GMT http://www.elated.com/forums/topic/5391#post22251
Re: Drag-and-Drop with jQuery: Your Essential Guide http://www.elated.com/forums/topic/5136/#post22250 From: rgsamways


Hi all,

Want to combine this example with a gallery-like feature where cardpile and cardslots have prev/next links at left and right such that a user can scroll horizontally through a number greater than 10. How best to do it?

Thanks..
Robin

View » | Reply »

]]>
Thu, 02 Feb 2012 19:03:38 GMT http://www.elated.com/forums/topic/5136#post22250
Re: How to Add Article Categories to Your CMS http://www.elated.com/forums/topic/5391/#post22249 From: hocfictum


Hullo, I fixed the second issue (date) but the notices are still bugging me -
Can you also point me in the right direction if I wanted to create a user(limited) who isn't allowed to add categories?

View » | Reply »

]]>
Thu, 02 Feb 2012 07:38:55 GMT http://www.elated.com/forums/topic/5391#post22249