Here is a snippet of my codes

<?php

$animesql = "Select titles.name FROM titles WHERE titles.cat_id = 1 ORDER by name ASC";
$animeres = mysql_query($animesql);

echo "<table id='MISC' style='display:none;' width='200' border='0' cellspacing='0' cellpadding='0'>";
  echo "<tr><td><p class='al_toggle_txt'>";
  
  
 while ($anime_list = mysql_fetch_assoc($animeres)) {
//$str = str_replace(" ","",$anime_list['name']);
$str = preg_replace('/[^a-zA-Z0-9]/','',$anime_list['name']);
 

    echo "<span style='cursor:pointer;' onclick='toggle_visibility('".strtolower($str) ."');'>".$anime_list['name']."</span><br/>";

  
  
  }
  
  
    echo   "</p></td></tr>";
echo    "</table>";
?>

after the while loop is done of course my list will show in my right column of site... but for the toggle, I have a div in the middle column waiting to be shown when the user clicks on the list name (right column).

and the codes are:

<div id='hackroots' style="display:none;"><h3>Hack Roots</h3>
    <p>TEST</p>
    </div>

but for sum reason the onclick from the PHP isnt letting my HTML codes work??? WHy is that and how can i fix this issue... Once I solve this issue i can upload my site...

Thanks in advance

echo "<span style='cursor:pointer;' onclick='toggle_visibility('".strtolower($str) ."');'>".$anime_list['name']."</span><br/>";

should be:

echo "<span style='cursor:pointer;' onclick='toggle_visibility(\"".strtolower($str) ."\");'>".$anime_list['name']."</span><br/>";

The browser is ignoring it because you need double quotes to encase the string.

Thanks for helping me solve this problem....

I have another question about this code too...

echo "<td align='left' valign='top' class='login_td'><p>
      <form><div class='login'><input type='text' value='Username' onclick='if(this.value=='Username')this.value='';' onblur='if(this.value=='')this.value='Username';' name='username' class='login_input' /><div class='login'><input type='password' value='Password' onclick='if(this.value=='Password')this.value='';' onblur='if(this.value=='')this.value='Password';' name='password' class='login_input' /><div><input type='image' src='img/login_btn.jpg' class='login_button' /></div></div></div></form></p></td>";
	  }

My Username and Password inputs arent clearing when i click on the input field any more....

How can i fix this issue as well??

Thanks in advance

You should make a script to handle that in the footer of your page, right below the </html> tag. Instead of this:

<input type='text' value='Username' onclick='if(this.value=='Username')this.value='';' onblur='if(this.value=='')this.value='Username';' name='username' class='login_input' />

Something like this:

<input type='text' id='username' name='username' onclick='checkUsername()' onblur='checkUsername()' value='Username' />

<script type='text/javascript'>
     function checkUsername() {
          var username = document.getElementById('username');
          
          if(username.value == 'Username') { username.value=''; }
          else if(username.value == '') { username.value='Username'; }
     }
</script>

You should make a script to handle that in the footer of your page, right below the </html> tag. Instead of this:

<input type='text' value='Username' onclick='if(this.value=='Username')this.value='';' onblur='if(this.value=='')this.value='Username';' name='username' class='login_input' />

Something like this:

<input type='text' id='username' name='username' onclick='checkUsername()' onblur='checkUsername()' value='Username' />

<script type='text/javascript'>
     function checkUsername() {
          var username = document.getElementById('username');
          
          if(username.value == 'Username') { username.value=''; }
          else if(username.value == '') { username.value='Username'; }
     }
</script>

I tried to put that in, but its still isnt clearing =/

Okay, I figured it out... I had to use \" everytime a quotation is needed such as:

echo "<td align='left' valign='top' class='login_td'><p>
      <form><div class='login'><input type='text' value='Username' onclick=\"if(this.value=='Username')this.value='';\" onblur=\"if(this.value=='')this.value='Username';\" name='username' class='login_input' /><div class='login'><input type='password' value='Password' onclick=\"if(this.value=='Password')this.value='';\" onblur=\"if(this.value=='')this.value='Password';\" name='password' class='login_input' /><div><input type='image' src='img/login_btn.jpg' class='login_button' /></div></div></div></form></p></td>";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.