Results 1 to 5 of 5

Thread: Highlight form element

  1. #1
    Join Date
    Oct 2009
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Arrow Highlight form element

    Hello,

    Using a link bid script that uses script from here:

    http://www.dynamicdrive.com/dynamici...hlightform.htm

    Add it is used for the dropdown.

    Example:

    http://constructionbannerexchange.co....php?su_categ=

    When you try to scroll and choose a catagory it dose Not allow you to do so.

    You would have to use arrow keys and users may not to be able to figure this out or just find it annoying.

    Is there a way to fix this issue? The linkbid admin dose Not have the answer.

    Thank you!

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    In future, please post about Dynamic Drive Scripts in the Dynamic Drive Scripts Help section here where I've moved this.

    The script is buggy as regards selects, especially in IE, but also to a lesser extent in others. I'd suggest removing them from the list. Change:

    Code:
    //Regular expression to highlight only form elements
    var intended=/INPUT|TEXTAREA|SELECT|OPTION/
    to:

    Code:
    //Regular expression to highlight only form elements
    var intended=/INPUT|TEXTAREA/
    As a side note, if onfocus is used instead of onkeyup and onclick, things improve. However, at that point the event must be applied directly to the element, using the form no longer works, so things get complicated. And they are still not ideal, the first click in IE doesn't drop down the list.

    But you can try it out if you like. Use this modified version of the script:

    Code:
    <script type="text/javascript">
    
    //Highlight form element- © Dynamic Drive (www.dynamicdrive.com)
    //For full source code, 100's more DHTML scripts, and TOS,
    //visit http://www.dynamicdrive.com
    
    var highlightcolor="green"
    
    var ns6=document.getElementById&&!document.all
    var previous=''
    var eventobj
    
    //Regular expression to highlight only form elements
    var intended=/INPUT|TEXTAREA/
    
    //Function to check whether element clicked is form element
    function checkel(which){
    if (which.style&&intended.test(which.tagName)){
    if (ns6&&eventobj.nodeType==3)
    eventobj=eventobj.parentNode.parentNode
    return true
    }
    else
    return false
    }
    
    //Function to highlight form element
    function highlight(e){
    eventobj=ns6? e.target : event.srcElement
    if (previous!=''){
    if (checkel(previous))
    previous.style.backgroundColor=''
    previous=eventobj
    if (checkel(eventobj) || e.type === 'focus')
    eventobj.style.backgroundColor=highlightcolor
    }
    else{
    if (checkel(eventobj) || e.type === 'focus')
    eventobj.style.backgroundColor=highlightcolor
    previous=eventobj
    }
    }
    
    </script>
    And add this onfocus event to any select:

    Code:
    <select name="selectc" id="selectc" onfocus="highlight(event);">
    This approach may have other problems though.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Oct 2009
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Very Nice: THANKYOU!

    The http://constructionbannerexchange.co....php?su_categ=


    is Now perfect.

    I tried to use the same html for contact page but recieved the following when I applied:

    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/63/7572563/html/directory/contact.php:1) in /home/content/63/7572563/html/directory/contact.php on line 1




    http://constructionbannerexchange.co...ry/contact.php

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by Comex View Post
    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/63/7572563/html/directory/contact.php:1) in /home/content/63/7572563/html/directory/contact.php on line 1
    That's a server side PHP error and probably means exactly what it says - That a cache limiter should be sent before the headers. Check the PHP code, or perhaps it was a fluke.

    In any case, changing the javascript should have no impact on that. If it wasn't a fluke, somehow the PHP code got changed, perhaps by working from an older version of the page. But it could have been anything.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    For sessions to work in PHP, the session_start() function MUST be called before any output of any kind. It must send a header, so if the headers are already sent (this happens once) then the session won't get started, and you get that error.
    This may or may not have anything to do with the script problems. It certainly not caused by the script though: this is a problem with the parsing of the PHP file, before any Javascript can execute.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •