Solved

How can I prevent my page from reloading after the "alert?"

Posted on 2014-04-16
2
162 Views
Last Modified: 2014-04-17
Here's my code:

$workqueueroleassigncheck = cer_workqueueroleassigncheck($tmp_entity[$i]["entityid"], $EntityID, $tmp_user[$k]["userid"]);
					if($workqueueroleassigncheck["count"]>0)
					{
					print '<script type="text/javascript">'; 
					print 'alert("be careful not to assign a role to the same person twice...!")'; 
					print '</script>';  
					}
					else
					{
					$workqueueroleassignsave = cer_workqueueentityassignsave($tmp_role[$j]["roleid"],$tmp_entity[$i]["entityid"],$EntityID, $tmp_user[$k]["userid"], $updateuserid);
					}

Open in new window


Basically, if the user attempts to add a record that's a duplicate of what's already in place, they get an alert and the insert code doesn't fire.

Problem is, I don't want the page to reload. Is there a way to structure my code where the checkboxes that had been checked remain so rather than the page reloading?
0
Comment
Question by:brucegust
[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
2 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40005316
What web framework are you using? PHP? ASP/ASP.NET? Other?

If ASP.NET, do you have your controls set to auto-postback?
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 40005420
That's PHP and to prevent it from reloading, you would have to call it with AJAX instead of posting to it.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

740 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