Solved

syntax error

Posted on 2014-09-16
12
179 Views
Last Modified: 2014-09-16
Not sure why I am getting a symtax error:

onclick="if(return confirm('You are about to clear the equipment from this rack')) { location.href='editrack.php?action=load&rackID=$_GET[rackID]';}"

Open in new window


Error from firebug:
SyntaxError: syntax error
      if(return confirm('You are about to clear the equipment from th..
0
Comment
Question by:Robert Saylor
  • 5
  • 4
  • 3
12 Comments
 
LVL 58

Expert Comment

by:Gary
Comment Utility
onclick="if(return confirm('You are about to clear the equipment from this rack')) { location.href='editrack.php?action=load&rackID=<?php echo $_GET[rackID]?>';}"

Open in new window

0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 250 total points
Comment Utility
What about : onclick="doIt();"
With in head section :
<script>
function doIt() {
    var b = return confirm('You are about to clear the equipment from this rack');
    if(b) { 
          location.href= 'editrack.php?action=load&rackID=<?php echo $_GET["rackID"]'; ?>'; // not it's PHP...
    }
}
</script>

Open in new window

0
 
LVL 6

Author Comment

by:Robert Saylor
Comment Utility
sorry meant to say it's a JS error not php error...
0
 
LVL 58

Accepted Solution

by:
Gary earned 250 total points
Comment Utility
Remove the return from the statement but you do have php code inside the js.
0
 
LVL 6

Author Comment

by:Robert Saylor
Comment Utility
I get the same error with the custom function...
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
what is : $_GET[rackID]

That's smell PHP.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 6

Author Comment

by:Robert Saylor
Comment Utility
I took the PHP out but still get the JS error.
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
@GaryC123 is right, did you removed the return ?
0
 
LVL 6

Author Comment

by:Robert Saylor
Comment Utility
http://www.javascriptlint.com/online_lint.php

                                function doIt() {
                                    var b = return confirm('You are about to clear the equipment from this rack');
                                    if(b) { 
                                          location.href= 'editrack.php?action=load&rackID=44';
                                    }
                                }

Open in new window

0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
<script>
function doIt() {
    var b = confirm('You are about to clear the equipment from this rack');
    if(b) { 
          location.href= 'editrack.php?action=load&rackID=1';
    }
}
</script>

Open in new window

0
 
LVL 58

Expert Comment

by:Gary
Comment Utility
onclick="if(confirm('You are about to clear the equipment from this rack')) { location.href='editrack.php?action=load&rackID=<?php echo $_GET["rackID"]?>';}"

Open in new window

0
 
LVL 6

Author Closing Comment

by:Robert Saylor
Comment Utility
Sorry Gary didn't see your 2nd reply. Removing the return fixed it. Thanks!!!
0

Featured Post

Highfive Gives IT Their Time Back

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

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

763 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

9 Experts available now in Live!

Get 1:1 Help Now