Wrox Programmer Forums
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 25th, 2012, 12:11 PM
Authorized User
 
Join Date: Dec 2011
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
Default Confirmation box

When the user clicks the submit button, a confirmation dialog box appears asking them if they want to continue. i am trying to pass a php variable to the js method, but it doesn't seem to like it. here is my code:

js:
Code:
<script type="text/JavaScript">
<!--
function show_confirm(str)
{
	var r=confirm("Are you sure you would like to change your username to " + str + "?");
}
//   -->
</script>
html:
Code:
 <?php $uname = "username"; ?>
<input type="submit" name="submit" id="submit" value="Submit" class="button" onclick="show_confirm($uname)" />
 
Old February 26th, 2012, 12:55 AM
Friend of Wrox
 
Join Date: Nov 2009
Posts: 156
Thanks: 13
Thanked 16 Times in 16 Posts
Smile use quotes and <?php

you should use quotes and <?php tag :

HTML Code:
<?php $uname = "username"; ?>
<input type="submit" name="submit" id="submit" value="Submit" class="button" onclick="show_confirm('<?php echo $uname ?>')" />
__________________
happy every time, happy every where

Reza Baiat
The Following User Says Thank You to irProject For This Useful Post:
droidus (February 26th, 2012)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Confirmation Messagebox sm.ibrahim BOOK: Professional Web Parts and Custom Controls ASP.NET ISBN: 0-7645-7860-X 1 January 30th, 2008 12:21 AM
Delete Confirmation From within a Gridview rit01 ASP.NET 2.0 Professional 5 March 8th, 2007 06:47 PM
Email Confirmation Katachi Dreamweaver (all versions) 1 December 18th, 2005 07:19 AM
delete confirmation yami56 Access 2 April 7th, 2004 12:09 PM
Pop up Delete confirmation box... developerz BOOK: ASP.NET Website Programming Problem-Design-Solution 1 October 8th, 2003 01:41 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.