Solved

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

Posted on 2014-04-16
2
150 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
2 Comments
 
LVL 74

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 82

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now