Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I wrote this line of code but is not giving expected output

please help me to find out the error in this code.

HTML
echo " <a class ='cl2' href='deleteprofile.php?id=$noticia[profileID]'  onClick='return confirm('Do
you really want to delete this Profile?')'>Delete Profile  </a><br>";
Posted
Updated 5-Oct-12 8:47am
v2
Comments
Joan M 5-Oct-12 14:25pm    
have not looked deeply into it, but that ö just at the beginning of onClick should be o and not ö...
Sergey Alexandrovich Kryukov 5-Oct-12 20:56pm    
This 'ö' is only the artifact of CodeProject script used to avoid "real" JavaScript handlers on the user-published code.
Yes, I'm sure. Try to add some onClick attribute to any element in your post to see it.
--SA
Joan M 5-Oct-12 23:44pm    
^^¡ OK, nothing to see here, move along please...

:D
Sergey Alexandrovich Kryukov 6-Oct-12 0:57am    
Excuse me..?
There is something to see, I tell you, but of course it's not so interesting that everyone would experiment with CodeProject input. Or perhaps you just did not understand me.
--SA
Joan M 6-Oct-12 4:44am    
I've not managed to explain myself:
I meant that I did not know what you explained: that the ö is a protection system in CP...
I don't know if that is a well known issue or not, I supposed that and not being aware of that I tried to joke about it diverting the attention... ;)

It was only a joke attempt... Of course you are right and it is interesting to know how they do that.

PHP
echo "<a class ='cl2' href='deleteprofile.php?id='" . $noticia[profileID] . "'   önClick='return confirm('Do
you really want to delete this Profile?')'>Delete Profile  </a><br>";


you need to escape $noticia[profileID] as it is a PHP construct and not an HTML one.
 
Share this answer
 
v2
Comments
[no name] 6-Oct-12 6:12am    
thanks
You need to use both sorts of quotes (single and double) for your onclick statement.
It also looks like you're using a php variable(profileID) to index into the array. If so, you forgot the $ prefix.

JavaScript
echo "<a class="cl2" href="deleteprofile.php?id=$noticia[$profileID]"  onclick="return confirm(\"Do you really want to delete this Profile?\")">Delete Profile  </a><br>";
</br>

or

JavaScript
$str =  "<a class="cl2" href="deleteprofile.php?id=$noticia[$profileID]" hold=" />
$str .= "  onclick='return confirm(\"Do you really want to delete this Profile?\");'>";
$str .= "Delete Profile</a><br>"
echo $str;</br>
 
Share this answer
 
v4
Comments
[no name] 6-Oct-12 6:12am    
thanks
i have solve my problem in my own way
thanks everyone

PHP
function confirmbox()
{
 var confirmed = confirm("Are you sure, You want to delete your profile?");
      return confirmed;
}


PHP
<a class="cl2" href="closeprofile.php"  önclick="return confirmbox()"> Delete Profile</a>


Thanks for your support
But I think this is the easiest way.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900