Jump to content

Confirm


SieRobin

Recommended Posts

the $_GET is a php variable, so you can just use it in the confirm (if the page is php)
[code]
confirm ("<?= addslashes($_GET['variable']) ?>");
[/code]
just make sure your variable doesn't have any line breaks.

Otherwise, you can take a look at this post

http://www.phpfreaks.com/forums/index.php/topic,102096.0.html

Link to comment
Share on other sites

[quote author=SieRobin link=topic=102901.msg409135#msg409135 date=1154634225]
problem is.. with a confirm the URL doesn't load until you pick "Ok" or "Cancel"
[/quote]

OK, I'm confused.  What exactly are you trying to do with the javascript confirm function?  Some specifics would help us point towards a solution (if one exists).
Link to comment
Share on other sites

I'm trying to make it so when a user sells an item, it shows a confirm that says.

"Are you sure you want to sell your $itemname for $howmuchgold Gold?"

How I do this, I don't know. I could make it so it doesn't show the variables.. BUT then they won't know what they're confirming or not.
Link to comment
Share on other sites

[code]$sellp=$uinventory3['cost']*.6;
$sell=$_GET['sell'];
$item=$_GET['item'];
$name=$_GET['name'];
$sellid=mysql_query("SELECT * from inventory where IID='$item' AND UID='$userstats3[ID]'");
$sellid2=mysql_fetch_array($sellid);
print "<td>$uinventory3[name]</td>";
print "<td><a href='inventory.php?sell=$sellp&item=$inventory3[IID]&name=$uinventory3[name]' onclick='return sellitem();'>$sellp</a> Gold</td>";
if (isset($sell)&&$item=$sellid2['IID']) {
if ($sellid2['status']==1) {
print "<table class='table'><tr class='headline'><td colspan='4'><center>Inventory</center></td></tr>
<tr class='mainrow'><td><center>You can not sell something that's equipped, please return to your <a href='inventory.php'>inventory</a> to unequip the item you're trying to sell.</center></td></tr></table>";
exit;
} else {
mysql_query("UPDATE users set gold=gold+'$sell' where ID='$userstats3[ID]'");
mysql_query("DELETE from inventory where UID='$userstats3[ID]' AND IID='$item'");
print "<SCRIPT language='JavaScript'>
location.reload('inventory.php')
</script>";
exit;
}[/code]

That's the code for selling the item.

[code]<script language="JavaScript" type="text/javascript">
var message="text";
function sellitem() {
return confirm("Are you sure you want to sell your " + message + " for $sell Gold?");
}
</script>[/code]

This is the javascript with the confirm.
Link to comment
Share on other sites

you need to pass the variables to the functions

[code]
.......onclick='return sellitem(\"$name_variable\", \"$price_variable\");'.......
[/code]

and your javascript
[code]
function sellitem(nm, prc) {
return confirm("Are you sure you want to sell your " + nm + " for " + prc + " Gold?");
}
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.