Link to home
Start Free TrialLog in
Avatar of arielbf
arielbfFlag for Israel

asked on

Dynamic toggle with php

The toggle here is not working...

<p><?php
                  $result = mysqli_query($con,"SELECT * FROM table WHERE qid=".$qid." ORDER BY RAND()");
                  while($row = mysqli_fetch_array($result)) {
                        if ($row['otxm']!=NULL){
                        echo "<span class='radioitem'>";
                        echo "<input type='radio' name='q".$_SESSION["nextPage"]."' value='".$row['scaleValue']."' onclick='toggleDisplay('toggle".$row['scaleValue']."');'>";
                        echo $row['scaleText']."<span id='toggle".$row['scaleValue']."' style='display:none;'>".$row['otxm']."<input type='text' name='otext".$row['scaleValue']."' /></span></span><br>";
                        }
                        else {
                        echo "<span class='radioitem'><input type='radio' name='q".$_SESSION["nextPage"]."' value='".$row['scaleValue']."'>".$row['scaleText']."</span><br>";
                        }
                  }
                  ?></p>
                  
                  
<script type="text/javascript">
<!--
    function toggleDisplay(id) {
            document.getElementById(id).style.visibility = "visible";
            if(document.getElementById(id).style.display == "none" ) {
                  document.getElementById(id).style.display = "";
            }
            else {
                  document.getElementById(id).style.display = "none";
            }
      }
//-->
</script>

I guess the problem is in onclick='toggleDisplay('toggle".$row['scaleValue']."');'
combining all these single/double  quotation marks.
Any Ideas?
ASKER CERTIFIED SOLUTION
Avatar of vr6r
vr6r

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of arielbf

ASKER

It is working now, Thank you