Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
| Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old January 24th, 2006, 12:19 PM
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default IE not performing onFocus event for <select>

Hi there,
I am having a problem with IE not allowing a CSS border to be drawn through javascript
in an onFocus event.

Here's an example:
<div class = "fieldname">Requester Name: <span style = "color:#FF0000"> *</span><br>
  <select class = "field"
          name = "Requester Info"
          id = "RequesterName"
          onFocus = document.getElementById('RequesterName').style.bor der = '2px solid #3EC4FE'"
          onBlur = "document.getElementById('RequesterName').style.bo rder = '2px solid #CCCCCC'">
          <option value = "Select your name">Select your name</option>
  </select>
</div>

so basically when the select gains focus, a border is drawn around it to show the user where they are in the form.

This code works just fine on Gecko/Mozilla/KHTML but does not work in IE, cannot figure it out.

Any help would be appreciated.

Thanks.
  #2 (permalink)  
Old January 24th, 2006, 12:30 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

You're missing a double quote:

onFocus = "document.getElementById('RequesterName').style.bo rder = '2px solid #3EC4FE'"

You can also do it this way and save space:

onFocus = "this.style.border = '2px solid #3EC4FE'"

HTH!

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
  #3 (permalink)  
Old January 24th, 2006, 12:41 PM
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey there,

Thank you for the response. I tried what you pasted in, no-dice.

Are you able to replicate this error on your machine? If so, let me know cos i'm starting to think that there is something in a JavaScript include that is causing this.

Thanks for the help,
IK
  #4 (permalink)  
Old January 24th, 2006, 01:35 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Oops, well, according to these MSDN documents the <select> object does not support the border property. Seemed like I used a border property on those before, but I guess I'm mistaken.

http://msdn.microsoft.com/workshop/a...cts/select.asp
http://msdn.microsoft.com/workshop/a...s/border_0.asp

The only way to work around that is to build your own <select> like object using JavaScript.

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
  #5 (permalink)  
Old January 24th, 2006, 02:10 PM
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for the links. i know for a fact that i have done that before using document.getElementById("").style.borderStyle, borderColor and borderWidth..

weirdness. i appreciate your help.


Similar Threads
Thread Thread Starter Forum Replies Last Post
<select> </select> prabhash_singh11 PHP How-To 2 March 11th, 2008 09:08 AM
select="<b>" AlDugan XSLT 8 March 24th, 2006 02:01 PM
<style> tags in a <body> vs. <div> bcat BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 March 27th, 2005 08:50 AM
HELP: XSL -> HTML <select selected=true> jedbartlett XSLT 4 October 7th, 2004 11:16 PM
<marquee><b>About CHAT App. in PHP4</b></marquee> Ramkrishna PHP How-To 1 September 11th, 2004 07:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.