0

i have done something like that;

    <div id="bloc2" onDblClick="document.getElementById('bloc2').style.height = 200px" style="width: 350px; height: 150px; overflow: auto; border: 1px solid #000;background-color:#F2F2F2">
Uncaught SyntaxError: Unexpected token ILLEGAL

but it doesn not work the div is generated using php, here is my code:

<?php 
$sql = "SELECT * FROM commentaire where n_doss='".mysql_real_escape_string($_GET['n_doss'])."' ORDER BY date DESC LIMIT 0,5";
$result = mysql_query($sql) or die(__LINE__.mysql_error().$sql); 
?>
    <?php
     $r=0;
     while($donnees2 = mysql_fetch_assoc($result)) {
      ?>
      <table cellspacing="10" cellpadding="10">
        <tr>
           <td width="128px">
           <?php if ($donnees2['etat']=="VR") {?>
                <img src="images/wallet.png" />
           <?php } else {?>
                <img src="images/newsletter.png" width="128" height="128" />
           <?php } ?>
           </td>
           <td>
             <div id="bloc<?php echo ++$r ;?>"                  
                  onDblClick="document.getElementById('bloc<?php echo $r ;?>').style.height = 200px" 
                  style="width: 350px; height: 150px; overflow: auto; border: 1px solid #000;background-color:#F2F2F2">
                <?php echo mb_strtoupper(html_entity_decode($donnees2['commentaire'])) ; ?>
            </div>

but nothing works, except mistakes in the console.

Kind regards.

0

4 Answers 4

1

In the line

<div id="bloc2" onDblClick="document.getElementById('bloc2').style.height = 200px" style="width: 350px; height: 150px; overflow: auto; border: 1px solid #000;background-color:#F2F2F2">

you have Javascript error:

document.getElementById('bloc2').style.height = 200px

The 200px should be a string, YOU HAVE TO ADD QUOTES so use this line instead:

document.getElementById('bloc2').style.height = '200px'
Sign up to request clarification or add additional context in comments.

2 Comments

Uncaught TypeError: Cannot read property 'style' of null suivi.php:945 ondblclick
The syntax is correct.. try to move the code into Function and call the function in onDblClick.
1

You can use this keyword and wrap 200px with quotes

<div id="bloc2" onDblClick="this.style.height = '200px'" style="width: 350px; height: 150px; overflow: auto; border: 1px solid #000;background-color:#F2F2F2">

Comments

0

Try this

<div id="bloc2" 
     onDblClick="this.style.height = '200px'" 
     style="width: 350px; height: 150px; overflow: 
     auto; border: 1px solid #000;background-color:#F2F2F2">

Uncaught SyntaxError: Unexpected token ILLEGAL

</div>

1 Comment

I guess issue is with this line <?php echo mb_strtoupper(html_entity_decode($donnees2['commentaire'])) ; ?> because above posted code works fine if you run it as it is, You should check your php div generation logic.
0

You forgot to add string "" with 200px

<div id="bloc2" onDblClick="document.getElementById('bloc2').style.height = '200px'" style="width: 350px; height: 150px; overflow: auto; border: 1px solid #000;background-color:#F2F2F2">

Demo

2 Comments

now it says Uncaught TypeError: Cannot read property 'style' of null suivi.php:945 ondblclick
check the demo link and remember who answer first

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.