Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 2 FirstFirst 12
Results 16 to 28 of 28
  1. #16
    New Coder
    Join Date
    Jul 2008
    Posts
    29
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by glenngv View Post
    Then change the form field names to the correct values.
    Yup. Sorry, I've turned brain dead. I'm still going to have to use js in the end because I want to make those drop downs appear in some cases and not in others, and short of some kind of scripting I don't see how I'd do that.

  2. #17
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,033
    Thanks
    0
    Thanked 248 Times in 245 Posts
    Right. You need js to do that. I'm not all against js. What I was just pointing out is not to rely on too much on it if something can be accomplished without it.

  3. #18
    New Coder
    Join Date
    Jul 2008
    Posts
    29
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Okay, hopefully final question regarding this form. Here's what it's supposed to do.
    1. If the user chooses keyword, an additional dropdown is shown to allow for a scoped search.
    2. Based on the searchtype option, a specific form action is written.
    3. Submit or enter runs the search.

    It works in FF and in Chrome, but in IE it's appending the search type on the keyword search (so instead of the search result being http://roc.curtis.edu/search/X?SEARCH=dowland&m=c it's http://roc.curtis.edu/search/X?=X&SEARCH=dowland&m=c).

    Here's the js:
    Code:
      var searchTerms = document.getElementById("searchtype");
       // selectedTerm = searchTerms.options[0].value;
    
    function searchChoice() {
      if(document.rocsearch.searchtype.options[document.rocsearch.searchtype.selectedIndex].value !== 'X') {
          //  alert("The search isn't a keyword search.");
            //termChange(selectedTerm);
            document.getElementById('m').style.display = "none";
            document.getElementById('SEARCH').name = "searcharg";
            document.getElementById('searchtype').name = "searchtype";
            
        } else {
          //  alert("The search is a keyword search.");
            //termChange(selectedTerm);
            document.getElementById('m').style.display = "";
           document.getElementById('SEARCH').name = "SEARCH";
           document.getElementById('searchtype').name = "";
                     }
    };   
       
    
    function chgAct(val){
    var searchAction = val.options[val.selectedIndex].className;
    //alert(searchAction);
    document.rocsearch.action = searchAction;
    };
    And here's the relevant html:
    Code:
    <form action="http://roc.curtis.edu/search/X" method="get" name="rocsearch" id="search">
    <!-- new form attempt -->
    <select name="" id="searchtype" onChange="chgAct(this);searchChoice();">
    <option class="http://roc.curtis.edu/search/X" value="X">Keyword</option>
    <option class="http://roc.curtis.edu/search~S0/" value="t">Title</option>
    <option class="http://roc.curtis.edu/search~S0/" value="a">Author</option>
    <option class="http://roc.curtis.edu/search~S0/" value="d">Subject</option>
    <option class="http://roc.curtis.edu/search~S0/" value="c">Call Number</option>
    <option class="http://roc.curtis.edu/search~S0/" value="i">Standard Number</option>
    <option class="http://roc.curtis.edu/search~S0/" value="b">Accession Number</option>
    </select>
    <input type="text" name="SEARCH" id="SEARCH" size="40" maxlength="75" value="" />
      <select name="m" id="m">
      <option value="c">Printed Music</option>  
      <option value="j">Sound Recordings</option>
      <option value="g">Video Recordings</option>
      <option value="a">Books</option>
      <option value="">Any</option>
      </select>
      <input type="submit"  value="Search"/>
      </form>
    All running at http://michelleoswell.com/opacmenu3.html. I'm sure there are more elegant ways of writing the code, but I managed to get it working with this in the browsers used most on my campus. However, I need a solution for IE to put this code in our actual catalog. Thanks in advance.

  4. #19
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,033
    Thanks
    0
    Thanked 248 Times in 245 Posts
    Try replacing this:

    Code:
    document.getElementById('searchtype').name = "";
    with:

    Code:
    document.getElementById('searchtype').removeAttribute('name');

  5. #20
    New Coder
    Join Date
    Jul 2008
    Posts
    29
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by glenngv View Post
    Try replacing this:

    Code:
    document.getElementById('searchtype').name = "";
    with:

    Code:
    document.getElementById('searchtype').removeAttribute('name');
    Nope. It still works in FF & Chrome, but it's not having any effect in IE. I tried
    Code:
    document.getElementById('searchtype').options[document.rocsearch.searchtype.selectedIndex].removeAttribute('value');
    as well. With this, I can put in the alert and see the value get removed in Firebug, but it just doesn't seem to do squat in IE.

  6. #21
    New Coder
    Join Date
    Jul 2008
    Posts
    29
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Moswell View Post
    Nope. It still works in FF & Chrome, but it's not having any effect in IE. I tried
    Code:
    document.getElementById('searchtype').options[document.rocsearch.searchtype.selectedIndex].removeAttribute('value');
    as well. With this, I can put in the alert and see the value get removed in Firebug, but it just doesn't seem to do squat in IE.
    Let me add, if I go in manually to IE's developer tool and remove the value=X from the keyword option, then submit the form, the search happens. It seems like IE just doesn't like my js and won't actually run the script the way I want it to (and the way FF and Chrome do).

  7. #22
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,033
    Thanks
    0
    Thanked 248 Times in 245 Posts
    You can disable the control to prevent it from being submitted.

  8. #23
    New Coder
    Join Date
    Jul 2008
    Posts
    29
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by glenngv View Post
    You can disable the control to prevent it from being submitted.
    I could and that works in part. However, I'd like keyword to be the first option on that drop down. If it is, then to make the script work in IE I'd have to disable that control when the page loads, which would mean that the user could then decide to use one of the other options (such as title or author).

  9. #24
    New Coder
    Join Date
    Jul 2008
    Posts
    29
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I think I may have found an answer. If I remove the name attribute from the initial code altogether, but leave in the .removeAttribute under the else statement, IE seems to accept the js and run it properly.

    I guess at this point I don't care why IE runs this differently than Chrome and FF, as long as it's working.

  10. #25
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    Quote Originally Posted by Moswell View Post
    I guess at this point I don't care why IE runs this differently than Chrome and FF, as long as it's working.
    IE isn't as DOM-compliant as FF or Chrome. Granted, it is taking baby steps in the right direction - IE8 is slightly more DOM-compliant than IE7; IE9 slightly more than IE8, etc.

    But this gradual progress makes it really difficult for developers, coz now you have to hack your code to run X if it's IE6, Y if it's IE7, Z if it's IE8, etc.
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

  11. #26
    New Coder
    Join Date
    Jul 2008
    Posts
    29
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by WolfShade View Post
    IE isn't as DOM-compliant as FF or Chrome. Granted, it is taking baby steps in the right direction - IE8 is slightly more DOM-compliant than IE7; IE9 slightly more than IE8, etc.

    But this gradual progress makes it really difficult for developers, coz now you have to hack your code to run X if it's IE6, Y if it's IE7, Z if it's IE8, etc.
    I guess I knew that this was the case, it's just other than CSS I'd never seen it in action before. It still is surprising though, and of course frustrating. The question is, is it more frustrating for the people who code for a living, or the people like me who just occasionally need to do a bit of coding?

  12. #27
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    Equally so, I think. I frequently feel the need to rip my hair out by its roots, when trying to make certain things work in IE7/8/9, FF, and Chrome.

    I don't even bother trying for IE6, anymore; and IE7 isn't too far behind to face the same. Gah.. (shudder,cringe).
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

  13. #28
    New Coder
    Join Date
    Jul 2008
    Posts
    29
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by WolfShade View Post
    Equally so, I think. I frequently feel the need to rip my hair out by its roots, when trying to make certain things work in IE7/8/9, FF, and Chrome.

    I don't even bother trying for IE6, anymore; and IE7 isn't too far behind to face the same. Gah.. (shudder,cringe).
    About an hour ago I walked over to my library's public catalog look-up station. It was running IE6. That's going to have to change now - there's no way I'm going to try to code for 6 or 7. Get with the times, people.


 
Page 2 of 2 FirstFirst 12

Posting Permissions

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