3

i wrote a code like this

<?php
$extCount = 0;
foreach($this->externalReferal as $externalReferal)
{
$extCount++;
?>

    <div class='fieldtestPct' >
      <div class='fieldItemLabel'>
                <label for=''><?php echo $externalReferal->getConsultantname(); ?> ( <?php echo $externalReferal->getSpeciality(); ?> )</label>
      </div>
        <div class='fieldItemValue'>
                <input type='checkbox' class='ext_ref_list<?php echo $extCount; ?>' name='ext_ref_cons[]' value="Consultant<?php echo $extCount ?>" >
         </div>
    </div>

<div class='fieldtestPct'>
      <div class='fieldItemLabel'>
                <label for=''>Current Visit</label>
      </div>
        <div class='fieldItemValue'>
                <input type='checkbox' class='current_visit<?php echo $extCount; ?>' name='current_visit[]' value="" onClick ='currentVisit(this.class)'>
         </div>
    </div>
<div class='fieldtestPct'>
      <div class='fieldItemLabel'>
                <label for=''>Full Data</label>
      </div>
        <div class='fieldItemValue'>
                <input type='checkbox' class='full_data<?php echo $extCount; ?>' name='full_data[]' value="" onClick='fullData(this)'>
         </div>
    </div>

                <div class='clear'></div>
<?php
}
?>

Here i need to do dynamic action on click of checkboxes. how do i pass the selected element class/data to javascipt .

1 Answer 1

3

Use this.className instead of this.class.

The name className is used for this property instead of class because of conflicts with the "class" keyword in many languages which are used to manipulate the DOM.

https://developer.mozilla.org/en/DOM/element.classname

Sign up to request clarification or add additional context in comments.

1 Comment

and how do i pass the Id of the element

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.