0

I am trying to use the following javascript code to alert the user when a form has been updated.

Basically what happens is a user clicks on a list of prospective clients, they click edit, this then loads all the clients details into an editor form. Once they have finished editing the user they click the update button and the contents are posted to a php processing script, which also has various other php functions in it that perform other commands before the user is then sent back to the prospect editor where the user details are re loaded into the form again with all the edits applied, this is all done in a second or two.

Once the update has been successful it adds a token into the GET array called update=1 which is passed in the url back to the editor.

What I am trying to do is alert the user when the clients record has been successfully updated by way of an alert box in javascript.

I am using the following code but am no sure how to get the javascript to look for the update=1 in the url and only display update successful when the client has been updated, and not on the initial load when the client is getting loaded from the list of clients.

JAVASCRIPT

<script language="JavaScript">

function prospectupdated () 

    {alert("Prospect Updated !")

}

</script>

HTML

<body onLoad="prospectupdated()">

As it stands at the moment it loads every time the page loads, whether the update=1 token in the url is there or not, does anyone know of any tutorials on how to do this, or knows how it do it themselves and doesn't mind sharing ? :-) Thanks

Iain Simpson
  • 8,011
  • 13
  • 47
  • 66

2 Answers2

2

You need to test the update:

<body <?php  isset($_GET['update']) && $_GET['update'] == 1  ? print "onload='prospectupdated()'" : '' ?>  >
  • Thanks, I have tried the above but get : Parse error: syntax error, unexpected ')' in /home/websit52/public_html/chandlers/components/com_chronoforms/libraries/includes/data_republish.php(24) : eval()'d code on line 9 – Iain Simpson Jan 27 '12 at 19:14
1

Look here: How to retrieve GET parameters from javascript?

It will show you how to obtain the value for the update=1.

You would then have an if() statement to check if update=1. If it does, then execute the alert().

Community
  • 1
  • 1
SpecialK77
  • 31
  • 2