October 28th, 2008 §
For a project of mine I had to make a dynamic filename
We decided that the name should always be seven digits long and the file would be correspondentĀ to the line number in the database. For example line seven would link to a file 0000007.txt.
code for the id from MySQL
$mynr = mysql_insert_id();
code for the seven digits
$mynr = sprintf(”%07d”,$mynr);
Related Blogs
October 27th, 2008 §
var mytime = new Date()
var mymonth = mytime.getMonth() + 1 // for javascript january = 0 correct this by adding 1
var myday = mytime.getDate()
var myyear = mytime.getFullYear()
document.write(mymonth + "/" + myday + "/" + myyear)
Beware that this is the date on the client's computer. For forms use the date on your server.
Related Blogs
October 23rd, 2008 §
example:
<input type='radio' name='test' value='1' />
<input type='radio' name='test' id='nr2' value='2' />
<input type='radio' name='test' value='3' />
$$("input[type=radio][name='test'][value='3']")[0].writeAttribute("checked", "checked");
or
$("nr2").writeAttribute("checked", "checked");
Related Blogs
October 21st, 2008 §
After some research I found the follow css code for sniffing out browsers and emailclients through css. /*Internet Explorer*/
<!--[if IE 7]>
.glue{color: black;}
<![endif]-->
<!–[if IE 6]>
.glue{color: blue;}
<![endif]–>
/* outlook 2007*/
<!--[if gte mso 9]>
.glue{color: aqua;}
<![endif]-->
/* Firefox */
@-moz-document url-prefix() {
.glue { color: red; }
}
/* Opera */
@media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0) { .glue { color: yellow; }
}
October 13th, 2008 §
Prototype’s stripTags function needs a string as input. If you want to access a dom node with this function, you need to acces the innerHTML, else the input won’t match.
expl.
alert($(’mydiv’).stripTags(); -> wont work
use
alert($(’mydiv’).innerHTML.stripTags();
Related Blogs
- Related Blogs on Prototypejs
- Related Blogs on striptags()
October 9th, 2008 §
Joe Gornick wrote a Prototype extension that lets users copy data to the clipboard.
The code uses javascript in Internet Explorer and some flash for other browsers.
Check it out at Joe Gornick’s site.
October 9th, 2008 §
When using $$ in Prototype, the result is an array. You need to loop through the array to attach the observe function. Expl.
$$(’.myitems‘).each(function(item) { item.observe(’click’,function(){alert (’clicked’)});});
or
$$(’.myitems’).invoke(’observe’, ‘click’, function() {alert(’clicked’)});
October 9th, 2008 §
Some things to keep in mind when using images:
- jpeg’s are for pictures
- gif was for logos, use png-8 instead (sidenote)
- use smushit.com to remove metadata
- when possible use tiles

October 9th, 2008 §
Make sure your variables in javascript are unique. They should not be used in id’s and classes. IE doesn’t like it. (Works fine in Firefox)
October 9th, 2008 §
It’s not possible to fire the default events with Prototype 1.6. Only custom events are supported.
$(’mybutton’).observe(’click’,function(){…});
$(’mybutton’).fire(’click’); will not work
$(’myinput’).observe(’input:changed’,function(){….});
$(’myinput’).fire(’input:changed’); does work