How to Lookup input value based on ID?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BaseballGraphs
    New Member
    • Sep 2010
    • 75

    How to Lookup input value based on ID?

    Hello,

    I am requiring some assistance in creating a function that will be able to look up and return a value based on an ID using javascript.

    I am having a user click a checkbox and the checkbox takes this structure:

    Code:
    <input type="checkbox" value="<?= $statistic_id; ?>" name="<?= $statistic_id; ?>"  id="checkbox_data" <?= $i==0 ? 'checked="checked"' : null; ?> />
    <label for="checkbox_<?= $statistic_id; ?>"><?= getStatisticFromId ( $statistic_id ); ?></label>
    There are about 20 different checkboxes and the value $statistic_id varies from a value of 1 to 20.

    I would like to select the checkbox based on the ID, then find its value, then return its value. How is this possible?

    I would really appreciate any sort of assistance you can provide. Thank you!
  • BaseballGraphs
    New Member
    • Sep 2010
    • 75

    #2
    It appears that by performing this function you can return the appropriate value
    Code:
    document.getElementById('checkbox_data').value;

    Comment

    Working...