?
Solved

Javascript onSubmit send on variable too

Posted on 2013-05-13
5
Medium Priority
?
237 Views
Last Modified: 2013-05-14
Currently we have users being listed and each row holds one entry, and with that there's three options Delete, Seat and Notify

Now clicking either of these first triggers a javascript pop-up that require a yes/no to continue, and then the action gets processed

I would like to send a PHP variable in this call, and as each row is looped out they will have different variables

This is the the current code:

<form method="post" action="http://<?echo $_SESSION["instance"];?>:8080" onSubmit="return confirmActionDelete()">
	<input type="hidden" name="method" value="removeUserFromQueue">
	<input type="hidden" name="clientId" value="<?echo $_SESSION['clientID'];?>">
	<input type="hidden" name="userPhoneNo" value="<?echo $Customer->phone?>">
	<input type="hidden" name="userId" value="<?echo $Customer->userId ?>" />
	<input class="btn red submit" value="DELETE" type="submit" />
</form>

Open in new window


So this is the form, and it triggers this Javscript
function confirmActionDelete() {
        return confirm("Are you sure you want to Delete this party?")
      }

Open in new window


This is looped out several times depending on how many users there are, each have individual name, ID etc

So I'm thinking I should be able to add the same PHP variable that is being looped out in this snippet somewhere, and then be able to get that in the top javascript ?

onSubmit="return confirmActionDelete([b]<?echo $Customer->name?>[/b])"

Open in new window


Or how can I get the pop-up to include the name of some other data ?

Thanks
0
Comment
Question by:DanteAdmin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 39162067
<form method="post" action="http://<?echo $_SESSION["instance"];?>:8080" onSubmit="return confirmActionDelete(this)">
	<input type="hidden" name="method" value="removeUserFromQueue">
	<input type="hidden" name="clientId" value="<?echo $_SESSION['clientID'];?>">
	<input type="hidden" name="userPhoneNo" value="<?echo $Customer->phone?>">
	<input type="hidden" name="userId" value="<?echo $Customer->userId ?>" />
	<input type="hidden" id="name" value="<?echo $Customer->name ?>" />
	<input class="btn red submit" value="DELETE" type="submit" />
</form>

Open in new window

with :
function confirmActionDelete(form) {
   var name = form.getElementById("name").value;
   alert(name); // testing purpose
}

Open in new window

0
 

Author Comment

by:DanteAdmin
ID: 39162568
When I have this snippet it doesn't bring up any notification, just goes straight to the next step and posts it

var name = form.getElementById("name").value;

Open in new window


Should I have any other values in the form for "this" and in the script for "form" ?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 39162592
check end of line 1
and line 6 is added
0
 

Author Comment

by:DanteAdmin
ID: 39162700
This is what I have no but it just skips the Javascript on that specific button

And as I mentioned there's more then one form, there's three peruser ... the javascript I'm using is below with the updated code for the delete

<SCRIPT LANGUAGE="JavaScript">
      function confirmActionNotify() {
        return confirm("Are you sure you want to Notify this party?")
      }
      
      function confirmActionDelete(form) {
   		var name = form.getElementById("name").value;
   		alert(name); // testing purpose
	}
      
      function confirmActionSeat() {
        return confirm("Are you sure you want to Seat this party?")
      }
</SCRIPT>

Open in new window


<form method="post" action="http://<?echo $_SESSION["instance"];?>:8080" onSubmit="return confirmActionDelete(this)">
	<input type="hidden" name="method" value="removeUserFromQueue">
	<input type="hidden" name="clientId" value="<?echo $_SESSION['clientID'];?>">
	<input type="hidden" name="userPhoneNo" value="<?echo $Customer->phone?>">
	<input type="hidden" name="userId" value="<?echo $Customer->userId ?>" />
	<input type="hidden" id="name" value="<?echo $Customer->name ?>" />
	<input class="btn red submit" value="DELETE" type="submit" />
</form>

Open in new window

0
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 39163521
I change the code on this Test page : http://jsfiddle.net/9zkjJ/
0

Featured Post

Tutorial: Introduction to Managing a Linux Server

In this tutorial on systemd, we will explore:
-OS/Distro Adoption
-chkconfig and Other Legacy Commands
-Summary and Key Commands

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question