Forum Moderators: open

Message Too Old, No Replies

Get php variable To JavaScript

         

nanat

9:33 am on Oct 28, 2009 (gmt 0)

10+ Year Member



it seem my code doesnt work..
php statement

for ($i = 0; $i < $limit; $i++)
{
$UserID = mssql_result($result,$i,"UserID");
<a href="delete.php?UID='.$UserID.'" onclick=" ConfirmChoice(); return false;"><img src="icons/trashcan.gif" border=0 alt="Delete" title="Delete"></a>
}

JavaScript

function ConfirmChoice(UID)
var UID = document.getElementById("UID").value;
getUrlVars()
{
answer = confirm("Are Sure You Want to delete?")

if (answer !=0)

{
location = "delete.php?UID="+ UID;
}


this statement doesn't work var UID = document.getElementById("UID").value;
whats wrong with this statement?

daveVk

11:28 am on Oct 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Javascript

function ConfirmChoice(UID)
var UIDval = document.getElementById(UID).value;
getUrlVars()
{
answer = confirm("Are Sure You Want to delete?")

if (answer !=0)

{
location = "delete.php?UID="+ UIDval; // or UID?
}

PHP, something like

ConfirmChoice("'.$UserID.'")

nanat

2:40 am on Oct 29, 2009 (gmt 0)

10+ Year Member



yes dave base on userID
location = "delete.php?UID="+ UIDval; // or UID?

i really get hard time to debug my java script and like php you can determine the value if empty or not by just echo $var ,'--'; statement.. but in JavaScript even if you document.write(UIDval); it doesn't show an error parse..

what is the best editor or tool for debuging javascript and DOm.. dave? tnx :bow:

daveVk

5:30 am on Oct 29, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Some of the tools/tricks I use

alert( UIDval ); // annoying if to many or to often
document.write // avoid this
debugDiv.innerHTML += "some msg"; // writes to div at say bottom of page

make sure preferences set to "show javascript errors"

DebugBar installed in IE
script debugger installed in IE (installed by default in latest ? )

Also jsLint tool integrated into say notepad++ editor is handy to detect errors prior to debugging.

nanat

9:12 am on Oct 29, 2009 (gmt 0)

10+ Year Member



thx dave ^^ :Bow: :bow: