SitePoint Sponsor |
|
User Tag List
Results 1 to 9 of 9
-
Jul 12, 2001, 08:43 #1
- Join Date
- May 2001
- Location
- Atlanta
- Posts
- 48
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
'how to use the 'toString' in java string for the conversion
HI,
Can someone help me with the converting the values to string by using the 'toString'. in java script.
Thank youAneal
-
Jul 12, 2001, 09:13 #2
- Join Date
- Oct 2000
- Location
- Austin, TX
- Posts
- 1,438
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
blah = 5;
blahstring = blah.toString();
blahstring = blah + ""; //equivalent hack
-
Jul 13, 2001, 06:16 #3
- Join Date
- May 2001
- Location
- Atlanta
- Posts
- 48
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks for reply.
I've made changes to the script. But it still giving me an error. Error '35kkl690o' is undefined. It sounds like iit didn't change to the string. I'm pasting my script here, Please let me know what I'm missing here. Thank you
<SCRIPT language = "javascript">
function confirm_box(staff)
{
var acc = eval(staff);
accstring = acc.toString();
document.write(acc);
var agree = confirm("Are you sure you want to delete this order?");
if (agree)
{
document.location ="<? echo $PHP_SELF; ?>?staff_id=<? echo $staff_id; ?>&delete=yes&staff="+accstring;
}
else
{
alert("Order is not deleted");
}
}
</script>Aneal
-
Jul 13, 2001, 08:40 #4
- Join Date
- Oct 2000
- Location
- Austin, TX
- Posts
- 1,438
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It's definitely not because of the string conversion, which you don't even need. I think it's probably due to your eval(staff) line, but I would need to see more of the page to tell.
-
Jul 13, 2001, 09:02 #5
- Join Date
- May 2001
- Location
- Atlanta
- Posts
- 48
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Here is my file:
<SCRIPT language = "javascript">
function confirm_box(staff_id)
{
var acc = eval(staff_id);
accstring = acc.toString();
document.write(acc);
var agree = confirm("Are you sure you want to delete this order?");
if (agree)
{
document.location ="<? echo $PHP_SELF; ?>?staff=<? echo $staff; ?>&delete=yes&staff_id="+accstring;
}
else
{
alert("Order is not deleted");
}
}
</script>
</head>
<?include ("database.php3");
include ("del_class.php3");
$link = connect_dbs($hostname, $username, $password, $dbname);
?>
<body>
<form name = "staff_id" method = "get" action="<? $PHP_SELF ?>">
<table> <tr> <td><input type=text name=staff</td>
</tr>
<tr>
<td><input type=submit value = "Login" name ="login"></td>
</tr>
</table>
</center>
</form>
<?
if ($delete == "yes")
{
delClass($staff_id);
}
if ($staff)
{
$sql = ("select * from orderlist a, staff b where a.order_id ='$staff'and a.order_id= b.order_id");
$result = mysql_query ($sql);
?>
$result = mysql_query ($sql);
while ($row = mysql_fetch_array($result))
{
?>
<table width=550>
<tr>
<td valign=top width=90>
<a href ="edit_class.php3?class_id=<?echo $row["class_id"];?>">Edit</a></td>
<td valign=top width=120>
<a href ="java script:confirm_box(<?echo $row["class_id"];?> )">Delete</a></td>
</tr></table>
<?
}
mysql_free_result($result);
?>
</tr></table>
<?
mysql_close($link);
exit;
?>
</body>
</html>Aneal
-
Jul 13, 2001, 09:05 #6
- Join Date
- Oct 2000
- Location
- Austin, TX
- Posts
- 1,438
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
If would help if you give us the html after php has run through it, so we know what data you're using. Also, on what line is the error?
-
Jul 13, 2001, 09:31 #7
- Join Date
- May 2001
- Location
- Atlanta
- Posts
- 48
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Here is the HTML version of parsed PHP code.
When I click on the delete I have an Error:'Error on page'.
<html>
<head>
<SCRIPT language = "javascript">
function confirm_box(staff_id)
{
var acc = eval(staff_id);
accstring = acc.toString();
document.write(acc);
var agree = confirm("Are you sure you want to delete this order?");
if (agree)
{
document.location ="<? echo $PHP_SELF; ?>?staff=<? echo $staff; ?>&delete=yes&staff_id="+accstring;
}
else
{
alert("Order is not deleted");
}
}
</script>
<DIV CLASS="BODY">
<form name = "signin_form" method = "get" action="index.php3">
<center>
<table>
<tr>
<td><input type=text name="staff"></td>
</tr>
<tr>
<td><input type=submit value = "Login"></td>
</tr>
</table>
</center>
</form>
<a href ="edit_order.php3?staff_id=65er38er1d">
<a href = "javascript:confirm_box(65er38er1d)">
</DIV>
</body></html>Aneal
-
Jul 13, 2001, 09:38 #8
- Join Date
- Oct 2000
- Location
- Austin, TX
- Posts
- 1,438
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Try this code:
<script type="text/javascript">
<!--
function confirm_box(staff_id)
{
if (confirm("Are you sure you want to delete this order?") )
document.location ="<? echo $PHP_SELF; ?>?staff=<? echo $staff; ?>&delete=yes&staff_id="+staff_id;
else alert("Order is not deleted");
}
-->
</script>
But that's not the correct HTML file, it still has $PHP_SELF and $staff in there, and there isn't even a delete link on the page.
-
Jul 13, 2001, 10:06 #9
- Join Date
- May 2001
- Location
- Atlanta
- Posts
- 48
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yes, there is a delete link on a file. Actually when I've tested it with only the numeric value'12345' it deleted that order. That's why I wanna change the values to the string.
The way program works is: First of all when the page is loaded after the login, then we have choices to Edit or delete the order. When we select edit it goes to the edit page. But when we select the delete option, the page reloads and call the javascript function in which we have if the $delete=yes then delete the order else Page is not deleted.
And the link to the delete class is:
<a href = "java script:confirm_box(65er38er1d)"> Delete Order
Here is the if loop which will call the delete function, from the file which is included in this file:
if ($delete == "yes")
{
delClass($staff_id);
}Aneal
Bookmarks