JQuery Mobile: Checkbox Issue

I have been trying to manipulate checkbox via JavaScript.
Long time spent to find out why the regular JQuery Code doesn’t work with JQuery Mobile.
Finally I resolved the issue.
Review the code below to understand the solution.

[javascript]
$(‘input.credits[chk="chk"]‘).attr(‘selected’,'selected’).checkboxradio("refresh");
[/javascript]

The code

.checkboxradio("refresh");

must be added every time the checkbox value changed.

PS Note:
Same rule probably should be applied to select element in jQuery Mobile Framework

[javascript]
$(‘.province_select’).attr(‘name’,'bill_province_2′).selectmenu(‘refresh’,true);
[/javascript]

One more snippet regarding this matter

[javascript]
$(‘select#provinces’).val(‘somevalue’).selectmenu(‘refresh’);
[/javascript]

How to redirect iPone users using PHP

// Redirect iPhone/iPod visitors
if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') ||
   strpos($_SERVER['HTTP_USER_AGENT'], 'iPod')){
      header("Location: http://mob.example.com");
}

User agent string for reference

//*
User Agent String for iPhone
    Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko)
    Version/3.0 Mobile/1A543a Safari/419.3
    
User Agent String for iPod Touch
    Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko)
    Version/3.0 Mobile/3A101a Safari/419.3
*/

Javascript: function showTime()

[javascript]
function showTime(){

myDate = new Date();

// Get time parts

hours = myDate.getHours();

minutes = myDate.getMinutes();

seconds = myDate.getSeconds();

// Just to display the time in a nice format

if (hours < 10) hours = "0" + hours;

if (minutes < 10) minutes = "0" + minutes;

if (seconds < 10) seconds = "0" + seconds;

actualTime = hours+":"+minutes+":"+seconds;

}
[/javascript]

Javascript: URL Validation

Javascript: url validating function

[code language="javascript"]

function isUrl(s) {
var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&amp;amp;%@!\-\/]))?/
return regexp.test(s);
}

[/code]

usage:
[code language="javascript"]
if (isUrl(&quot;http://www.page.com&quot;))
alert(&quot;is correct&quot;)
else
alert(&quot;not correct&quot;);
[/code]

JavaScript Switch Statement

JavaScript Switch Statement

Syntax

[code language="javascript"]
switch(n)
{
case 1:
execute code block 1
break;
case 2:
execute code block 2
break;
default:
code to be executed if n is different from case 1 and 2
}
[/code]

Example

[code language="javascript"]
&lt;script type=&quot;text/javascript&quot;&gt;
//You will receive a different greeting based
//on what day it is. Note that Sunday=0,
//Monday=1, Tuesday=2, etc.

var d=new Date();
var theDay=d.getDay();
switch (theDay)
{
case 5:
document.write(&quot;Finally Friday&quot;);
break;
case 6:
document.write(&quot;Super Saturday&quot;);
break;
case 0:
document.write(&quot;Sleepy Sunday&quot;);
break;
default:
document.write(&quot;I'm looking forward to this weekend!&quot;);
}
&lt;/script&gt;
[/code]