...

View Full Version : FF but not IE, typical.



martynball
07-24-2010, 12:41 AM
Yeah, as usual IE sucks.

JavaScript:


function background_text(obj, fun) {
//Get the id of clicked field
var id = obj.id.split("input_"); id = id[1] + "_bg";

switch (fun) {
//Remove the content from the background div
case "remove":
document.getElementById(id).innerHTML = '';
break;

//Add the content back into the div
case "add":
if (obj.value.length == 0) {
document.getElementById(id).innerHTML = document.getElementById(obj.id).getAttribute('btext');
}
break;
}
}


HTML:


<?php
//Get variable from request to send back correct form
$form = $_GET['form'];
switch($form) {
case "login":
?>
<form name="login" class="login">
<label for="username">Username: </label><br />
<div id="username_container">
<div class="input_field" id="username_bg">Username</div>
<input type="text" name="username" id="input_username" onclick="background_text(this, 'remove')" onblur="background_text(this, 'add')"
btext="Username..."/>
</div>
<br />
<label for="password">Password: </label><br />
<div id="password_container">
<div class="input_field" id="password_bg">Password</div>
<input type="password" name="password" id="input_password" onclick="background_text(this, 'remove')" onblur="background_text(this, 'add')"
btext="Password..."/>
</div>
<br />
<label for="remember">Remember Me? </label><br />
<span class="remember">
<span class="text">Never</span>
<input type="hidden" value="never" name="rememberme" />
<ul>
<li>Never</li>
<li>24 Hours</li>
<li>1 Week</li>
<li>Always</li>
</ul>
</span>
</span>
<?php break; case "register": ?>
<form name="register" class="login">
<label for="username">Username: </label><br />
<div id="username_container">
<div class="input_field" id="username_bg">Choose a username...</div>
<input type="text" name="username" id="input_username" onclick="background_text(this, 'remove')" onblur="background_text(this, 'add')"
btext="Choose your username..."/>
</div>
<br />
<label for="password">Password: </label><br />
<div id="password_container">
<div class="input_field" id="password_bg">Choose a password...</div>
<input type="password" name="password" id="input_password" onclick="background_text(this, 'remove')" onblur="background_text(this, 'add')"
btext="Choose your password..." />
</div>
<?php break; case "recovery":
break;

}
?>

Old Pedant
07-24-2010, 01:02 AM
??? Worked the same for me in FF 3.6 and MSIE 7.

martynball
07-24-2010, 01:22 AM
Why do my browsers seem to hate me today :( I will post more information tomorrow, sleep time :)

Philip M
07-24-2010, 12:03 PM
Yeah, as usual IE sucks.


Ever heard about the bad workman who blames his tools?

martynball
07-24-2010, 03:27 PM
Everything I code though works in FF but not always IE, always have to tweek the code or add more for it. I hate IE. I hate M$ for that matter.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum