开发者

Pass a php variable to dynamically generated div's onclick event

how to pass a php variable to dynamicaly generated div's onclick event?

here is my code

while($rowset = mysql_fetch_array($result))
    {
    $idTT1++; 
    $editTT='b'.$idTT1;
    $hidTextTT='t'.$idTT1; $hidSubIdTT='s'.$idTT开发者_开发问答1;
    echo "<tr><td>".$rowset[1]." ".$rowset[2]."</td><td> &nbsp; </td> 
    <td class='table_label'>
    <div id='".$idTT1."' onclick='editView($idTT1,$editTT)' >".$rowset[3]."</div>";

    echo "<div id='".$editTT."' style='display:none;'>          
        <input id='".$hidSubIdTT."' name='box1' type='hidden' value='".$row['dDegreeName']."'>
        <input id='".$hidTextTT."' name='box2' type='text' value=''  />
        <input type='submit' value='Update' name='submit' 
        onclick='updateSubject($hidSubIdTT,$hidTextTT)'/>
        <input type='button' value='Cancel' name='Cancel' onclick='setEditView($idTT1,$editTT)'/>
    </div></td></tr>";
    }

i want to pass 2 variables $idTT1 and $editTT. im getting the value of $editTT1 in javascript but i cant get value of $editTT value in editView() javascript function.


That is probably because you are not quoting the IDs. Try

setEditView(\"$idTT1\",\"$editTT\")

in the line before last.


You need to put it between quotes. Something like this should work:

"<input type='button' value='Cancel' name='Cancel' onclick='setEditView(\"$idTT1\",\"$editTT\")'/>"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜