jooskim / jquery-selectutility

This small jQuery plugin lets you easily fetch database-safe value or human-readable text from a select element.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jquery-selectutility

Retrieve machine-readable (database safe) value from Select node

  • Signatures
    • $(select element).mrValue();

    • $(select element).mrValue(domAttributeWhereMachineReadableValueIsSaved);

      • domAttributeWhereMachineReadableValueIsSaved defaults to 'data-value' if not specified as shown in the first signature

      • $('select#test').mrValue('data-somecustomname');

    • $(select element).mrValue(domAttributeWhereMachineReadableValueIsSaved, humanReadableOptionText);

      • If not specified, humanReadableOptionText will take its value from the option element currently selected
      • $('select#test').mrValue('data-value', 'Something Below the Currently Selected Option');
  • Return Values
    • Returns String when a match is found. If not, -1 is returned

Retrieve human-readable value from Select node based on machine-readable value

  • Signatures
    • $(select element).hrValue(domAttributeWhereMachineReadableValueIsSaved, machineReadableText);

      • $('select#test').hrValue('data-value', 'value_from_db');
  • Return Values
    • Returns String when a match is found. If not, -1 is returned

About

This small jQuery plugin lets you easily fetch database-safe value or human-readable text from a select element.

License:MIT License


Languages

Language:JavaScript 100.0%