View Full Version : Can you have more than one event on an <INPUT> event attribute?
Burgin
08-04-2010, 09:53 AM
I have two <INPUT> tags that separately work OK...
<input name="ysearch" id="ysearch" type="text" value="Search" onKeyPress="checkKey()" onFocus="if (this.value=='Search'){this.value='';};return false;" onBlur="if (this.value==''){this.value='Search';return false;}">
and
<input name="ysearch" id="ysearch" type="text" value="" onKeyPress="checkKey()" onFocus="javascript:collapseQS.slideit()" onBlur="javascript:collapseQS.slideit()">
Can the two different onFocus and onBlur events be merged so two events take place?
Beverleyh
08-04-2010, 11:40 AM
Yes, you should just be able to combine them by putting a semi-colon between;
Burgin
08-04-2010, 01:09 PM
Thanks Beverleyh but that doesn't work. It achieves the Search insert but doesn't invoke the javascript. I've tried it with the javascript event first but it's just the same.
You can see the javascript working here (searchBox top-right)...
http://www.barlborough.org/index.htm#home
Here's the same page but with the events combined...
http://www.barlborough.org/index-test-1.htm#home
Beverleyh
08-04-2010, 01:46 PM
Lose your current Search insert and try this one instead;
In your head section;
<script type="text/javascript">
function clearText(field){
if (field.defaultValue == field.value) field.value = '';
else if (field.value == '') field.value = field.defaultValue; }
</script>
Your revised input field;
<input name="ysearch" id="ysearch" type="text" value="Search" onKeyPress="checkKey()" onFocus="javascript:collapseQS.slideit();clearText(this)" onBlur="javascript:collapseQS.slideit();clearText(this)">
Burgin
08-04-2010, 02:01 PM
That's cracked it... ta very much. Your time's appreciated.
Beverleyh
08-04-2010, 02:11 PM
No problem - BTW - I'm from your neck of the woods (Chesterfield)
Small world, eh?
Burgin
08-05-2010, 03:48 PM
Sure is... BTW Fast-Edit looks very interesting, could be just what I'm looking for.
Beverleyh
08-06-2010, 07:25 AM
Good stuff - Fast Edit 2 is coming out in a few months though and that has an automatic sub-category/multi-level menu, so keep checking back for updates :)
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.