Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Well, this is most distressing! There's another file in there... combo_old.html, I think. It worked everywhere but MSIE. I'll have to figure out what's going on in the Mozilla browsers. A quick play with the JS Console found nothing! I'll get Venkman on the case.

    Patches welcome.
    --
    rjbs
    • <html>

      <form id='form'>
          <select id='line_dropdown' name='line' onChange='conditional_toggle(this)'>
              <option value=''>(undefined)</option>
          <option value='10'>ten</option>
          <option value='20'>twenty</option>
          <option value='30'>thirty</option>

          <option value='!-@-!'>(other)</option>
          </select>
          <input type="text" name="line" id="line_input" style="display: none;" onblur='conditional_toggle(this)'/>
      </form>

      <script>

      function conditional_toggle(el) {
          var drop = document.getElementById("line_dropdown");
          var inpt = document.getElementById("line_input");
          if( can_be_seen( el ) && has_special_value( el ) )
          {
              toggle_view( drop );
              toggle_view( inpt );
          }
          if( can_be_seen( drop ) && has_special_value( drop ) )
          {
              drop.options.selectedIndex = 0;
          }
          if( can_be_seen( inpt ) )
          {
              inpt.focus();
          }
      }

      function can_be_seen(element)
      {
          if( element.style.display == 'none' )
              return false;
          return true;
      }

      function has_special_value(element)
      {

          if( element.tagName.toLowerCase() == "select" && element.options[element.selectedIndex].value == "!-@-!" )
          {
              return true;
          }
          if( element.tagName.toLowerCase() == "input" && element.value == "" )
          {
              return true;
          }
          return false;
      }

      function toggle_view(element) {
          if( element.style.display == '' )
          {
              element.style.display = "none";
              return;
          }
          element.style.display = '';
      }

      </script>

      </html>
      • I'd rather make the new one work in firefox than the old one in MSIE! What's the issue here? Is it the use of a non-standard attribute?

        Also, because you're hiding the field and not removing it, it will submit its value, making the form processing logic uglier. It has to be removed or disabled (in WebKit, only the latter will work) to keep it from being submitted.
        --
        rjbs
        • I was thinking the backend would recieve the same data if it were a multi-select, so it would not get too ugly. On the other hand disabling it would be easy, element.disable = true; Adding and removing elements from the dom has always been a cross browser pain.