How to clear default text field value in a form with Javascript

JavaScript

<input id=”id” title=”Click to enter missing mandatory information” name=”id” type=”text” value=”Missing value!” onClick=”if(this.value==’Missing value!’){this.value=”;this.className=”;}” onblur=”if(this.value==”){this.value=’Missing value!’;this.className=’empty_text_field’;}” />

The idea here is that ‘onClick’ checks if the default value is in the field.
If it is, it clears the text field when you click on it. So if you type in anything else in the field, it will stay there.

CSS

I also added some CSS that changes the field to bright red if there’s missing information. It also turns to default styling as JavaScript removes the CSS class name.

Here’s the css:

.empty_text_field
{
border:2px solid red; /* Colours the text field border */
color:red; /* Colours the text */
}

Example

‘Missing Value!’ is the default text

An example of a text field default value being cleared via Javascript onClick attribute

 

Your questions

If any, please ask!!

Cheapest UK digital camera that’s half decent and ok looking

FujiFilm generally makes digicams that do great pics for value for money. They go even further for your money with their refurbished cameras.You can buy these directly from their web site and buy extra warranty for very little.

Being really poor at the time, I was looking for a ridicolously cheap digital camera, that would still be OK to use.

After some Google shopping and ebay sifting, this is what I concluded was the best bang for the buck that comes with a decent UK warranty:

https://secure.fujifilm.co.uk/shop/consumer/digital/digital-cameras/fun-and-easy/finepix-jx530

£49.99*(includes a free 4GB SDHC Class 4 Memory Card!!)

features worth pointing out:

  • 28mm Wide angle
  • 720p HD 30fps video

*As on 21st April 2011

Loose weight with these no brainer tips – and keep a slim state of mind

Becoming slim isn’t about cutting down on your food, exercising and “being good”, it’s a lifestyle change. The kind where when you arrive at a new lifestyle, you realise what perks you’ve been missing in your life all this time.

  • Recognise the frenzy you get into when youre eating – you are driven by a primeval instinct that you do not know where your next meal is coming from. You do. it’s only your frenzied state telling you you should fill up to the brim.Eating less never feels rewarding, so It will be hard at first.This will work for you eventually, and you’ll start eating food to sample various flavours of it, not just to fill a hole.
  • Start your day with a cup of herbal tea, with little sugar – warm liquid in your stomach is comforting and sugar will provide you with that first burst of energy
  • Eat a decent breakfast followed by fruit and a omega-3 supplement
    Eat a reasonable lunch (under 600 calories), fill up on fresh salad.
    Eat a light salad or snack for dinner – just something to kill the nagging hunger. You don’t need calories 2-3 hours before sleep. The food you’ve eaten troughout the day should provide enought energy for the strenuous task of sleeping.
  • Drink water whenever you can. Keep water in front of yourself, you’ll find yourself drinking it troughout the day. You can drink up to 5 litres a day, no problem. Downside is you will be going to toilet more frequently. This should do something for your skin too.
  • Walk whenever you can, it might hurt at first but after a few weeks you’ll feel like your overall shape has improved dramatically. Increase the distances, and at a brisker pace.
    This will save you funds and hours wasted on a treadmill.
  • Recognise calories in mayo, chocholate spreads, butter, cheese, bannanas and grapes. These things are so calorie rich that they can make you fat in no time.
  • Even if you crack under pressure, these slip-ups will become less and less.
  • Being slim is a state of mind. What I mean by that is that you can actually reason yourself with logic to what’s good for you, and this same reasoning will become a part of who you are, not a nagging reminder.
  • It takes months and years. But as a man wiser than myself said: “even a 1000 mile journey starts with a single step”.

Batiste Dry Hair Shampoo

Dry hair shampooIf you’re meeting someone in 5 minutes, and you’re as greasy as a used cotton wool earbud, spray this on, you’ll appear brand new!

Apparently spraying white powder in your greasy hairs makes grease vanish. There’s something unholy about this.

Buy it, now. Keep it in your car. The reason I say ‘car’ is, if you have it in your handbag, you can look a bit homeless.

Caution: DONT GET HOOKED

‘Just this once’ can turn into 3 days of postponing to wash your hair.

Turning on a PC with remote control socket switch

This shit is the ultimate sub £10 pimp up for ur PC. I kinda thought would be good way to save some dosh on wasted stand-by electricity, but then I found out there some setting in BIOS where you can make a PC turn on when power comes on. Now thats some random awesomness right there.

I got this wireless keyboard & mouse with which I shut it down.

What to buy

Maplins had some bitchin deal on these, I bought 3, for these purposes:

  • 1st for the internet box (router, modem, etc)
  • 2nd for the monitor – how much power do these waste when youre just listening to music or can’t get of your arse to turn em off for whatever other reason
  • 3rd to shut everything else off – PC, Sound Amp, Projector – etc (you can hook one up to a 3 way plug for example)

Remote PC power

CPU heatsink – a massive step towards a quiet computer

Hate the pointless noise computer fans make?

When you think about it, computer fans are ridicolous, really. There belong into the same box where history put the fan waving servants. And out of all of them, the CPU fan is the biggest offender by far. It’s coz CPUs are such hot potatoes, and it has to spin like mad to keep em cool. So by taking the route of CPU heatsink, you’ll be eliminating this Kingpin, and taking away a lot in terms of pointless noise.

Anyways, I got this cooling tower attached to my quad core. And yes, sadly, I still got 2x14cm slow turning fans doing their work as quietly as possible (9-12db) at 500rpm, one pushing the air into the case, other one churning it out. But finnaly, I can hear myself think. And movies don’t sound like they’re being screened in a tropical prison.

Why replace a CPU fan with a massive heatsink?

  • They last forever. And ever.
  • If you’re into fads: it’s eco
  • Looks awesome
  • people are gonna be like “whuuut. I wanna.”

Where to get it?

  • ebay sometimes has them. I got mine for £15, mint condition, local pickup, lovely man to deal with.
  • search google shopping, you might find a shop that does it under £30.

Tips on buying

  • Dont waste money on copper ones that cost 3 times more. Theyre about 1.5-2 times heavier than standard steel or aluminium ones, but cool like 10-20% better.
  • It doesn’t have to be the one I got, just get whatever cheapest, fits your CPU, and does the job (google reviews/forums for that)

Canon G11 digital camera – best compact in the world (2010)

Since SLRs are cameras that require cars to be driven around, I thought I should go for something that won’t be cutting into the back of my neck with its strap, or leaving my chest blue from pouncing on it when I walk around.

So soon I had a shortlist of super compact cameras that need proper looking into.

First in line for small size, high performance cameras was the “four thirds” cameras that promised near SLR performance, but turned out to be a fucking joke in terms of the prices. Average of £600 for the body with some average joe lens. The fuck.

Next I looked at called Panasonic LX-3. It’s a £300 clone of a £700 Leica D-Lux 4, but it can’t zoom for shit. 2.6 zoom, what were they thinking?

Then this beauty came into my sights. And after reading pretty much every respectable blog about the Canon G11 on the internet, where camera lovers were cuming in their pants globaly, I added it to my shopping list.

Canon G11 was a bit pricey even at its lowest ebay price (round £360), but then this lady from work was going to USA and I got it for £280. It didn’t come with worldwide warranty, but as all bloggers swore that it carried the built quality of a flagship model, I decided I should classify it as a calculated risk and prep myself for some crying when it doesn’t work first time I try to switch it on.

By the way, whatever you read about the viewfinder, it is not useless. It cuts the view to 70% of the original photo. You loose a bit what you can see trough it, but you loose nothing from the photo.
It’s possible that people who say it’s useless don’t realise that a regular point-and-shoot-sometimes-arty photographer cares about this viewfinder issue in a same way your grandmother cares what version of windows she is on.

Accessories that will make it rule 

Carry case

Bought on ebay for about £12. Looks genuine Canon. Once the camera is in, it’ll keep it away from damage. Easy to remove top, no obstruction when shooting. It’s ability to be invisible under even a light jacket should prevent you looking like a self-involved quarter aged person that’s got no game.

Polariser lens

It ads colours and vibrance to any watery landscape shots, and gives depth to the sky. Apparently it also does wonders when shooting glossy cars at motor shows.
Don’t buy cheap generic, get the cheaperst brand name.
- I bought a Hoya filter for £22 on ebay (uk seller).
You will need an adaptor to put it on camera.
- Mine was about £6, from ebay, some nice chap in Singapore took 3 weeks to post it.

External flash

It can also take flash, on which you can stick a home made diffuser on. I saw some finkelroy having it made out of a pint milk canister. His pics looked dramatic with this dark grain over them, like it was the 1920ties jazz cabaret, but yet very well lit, with all detail there. So if you feel like moonlighting at a budget wedding (it’s the ones with a buffet and a hip-hop dj), or would like to go to free gigs under a false pre tense your fanzine will get them exposure, having an external flash should be a part of your kit.

Wired remote

This should costs under £5 on ebay, and it should remove judder and camera shake you cause when pressing the shutter. I’m talking about night shot’s with no flash, or close up macro.(both from a tripod)
And people might even mistake you for some kind of a pro.

By the way, I know the title says “best compact” – compact it ain’t. Considering what else is in the general compact camera category, like this sony camera. If you want something that would fit into your skinny jeans ass pocket, and would make great facebook picures in style of “this-party-was-hmmaazing (we actually sat around all night coz no one was fit and just posed for the pics)” , Sony DSC-TX9 is it.

Sanyo Eneloop rechargeable batteries

  • Top characteristic: Old rechargeable batteries (both nicd and nimh) would loose up to 40% charge within 2 weeks. These retain 85% for up to a year.
  • Same price as Duracell, but can be reused a 1000 recharges.
  • Real pretty to look at, don’t look massively evil like other batteries.
  • Ready to use out of the box – doesn’t need charging when used first time.
  • Non-rechargable batteries are a waste of money. If not recycled or disposed of properly, it’s a poison when put into the ground.

Cheapest so far(25-Aug-2010):
http://www.modelsport.co.uk/?CallFunction=ShowSpecification&ItemID=35676

Check / Select All checkboxes with javascript

Description:

‘select / unselect all’ checkbox that does it to all checkboxes in a form via its ID.

Javascript:

<script language=”javascript” type=”text/javascript”>

function selectall(formid,selectallcheckbox)
{/* dom path to your form via the form’s id */
var formdompath= document.getElementById(formid);
/* ‘formdompath.elements.length’ tells it how many input elements the form contains, so as long as ‘i’ is less than it, it will continue looping, trough the array of elements */
for (i=0; i<formdompath.elements.length; i++)
{/* if/else statement that first sees if the ‘select all’ checkbox is checked or unchecked, and then it copies that checked or unchecked state to all other boxes */
if(selectallcheckbox.checked = true)
{
formdompath.elements[i].checked = true;
{
else if (selectallcheckbox.checked = false)
{
formdompath.elements[i].checked = false;
}
}
}
</script>

XHTML:

<form id=”myformid”>

<input type=”checkbox” name=”1″ value =”1″ />1<br />

<input type=”checkbox” name=”2″ value =”2″ />2<br />

<input type=”checkbox” name=”3″ value =”3″ />3<br />

<input type=”checkbox” name=”4″ value =”4″ />4<br />

</form>

 

<input type=”checkbox” name=”selectall” onclick=”javascript:selectall(‘myformid’,this);” />

Please note, to make this work, you should:

  1. Place the ‘select all’ box outside the form tags of the form whose boxes you wish to select/unselect
  2. Place the internal Javascript  / link to external Javascript file into the footer of the page. So it works in Firefox. I think it has something to do with the way Firefox loads file i.e. bottom to top. Please correct me if I’m wrong on that one.