Script

Filter
2007-04-13

Submit a form with an image

Javascript
Hur man kan använda en bild som submitknapp
<a href="javascript:document.f1.submit();" class="button"><img src="img/ok.jpg" width="58" height="18" alt="" /></a> 
2007-03-31

Select meny

Javascript
Select meny med onchange
<form action="">
<select name="choice" size="1"
        onchange="location.href='index.php?choice=' + 
        this.options[this.selectedIndex].value;">
    <option value="1">Första</option>
    <option value="2">Andra</option>
    <option value="3">Tredje</option>
</select>
</form> 
2007-01-13

CSS för alla webläsare

Css
Fixa ditt style-sheet för IE
Step 1. Make a CSS normal.css that works in standards-compliant browsers (like Firefox or Opera).

Step 2. Add this line to every page of the site <!--[if IE]><style type="text/css">@import "ie_fixes.css";</style><![endif]--> 

Step 3. Make a (blank) CSS ie_fixes.css and restate all the properties in the normal CSS,
that don't work as intended in IE, in this new file. They will override the normal CSS. 

Step 4. Make sure the CSS actually works the same in IE 6 and IE 7.
Otherwise use a different fixes css file for each version. 

How does it work? This is called conditional commenting. IE sees the new CSS file and uses it,
whereas other browsers just ignore the whole thing as if it were a usual comment.

<!--[if IE]><style type="text/css">@import "ie_fixes.css";</style><![endif]-->
	
You can replace [if IE] with [if IE 6] (or any other version) so that only IE 6 will use the CSS.
You can also use [if lt IE 6] to match browsers of versions lower than 6 (or gt for greater than).

It is actually a bad idea to finish a site and only then start creating the ie_fixes.css file,
because it will not be very clear where the problems come from. You should fix each problem in
the ie_fixes.css file when it arises rather than let them build up.
2006-12-22

Importera CSS

Css
Importera CSS i stället för att länka
One method for hiding CSS from older browsers is to use "@import".
You can use two different style sheets for your CSS; one CSS file for general styles
(for any browsers that support basic CSS) and another CSS file for advanced styles
(for full CSS supporting browsers only). This second file is imported rather than linked. For example: 

<style type="text/css" media="screen">@import url("advanced.css");</style>
<link rel="stylesheet" href="general.css" media="screen" />
2006-11-18

Ändra datum i SQL

Sql
Vissa funktioner i php för windows (mktime och getdate) hanterar inte datum älder än 1972 - ändra alla tidigare datum
update calendar set date = concat('1972-', substring(date,6 ,5)) where date < '1972-01-01'
🙂