?
Solved

syntax error

Posted on 2014-09-16
12
Medium Priority
?
188 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
[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
  • 5
  • 4
  • 3
12 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40326847
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 1000 total points
ID: 40326850
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 7

Author Comment

by:Robert Saylor
ID: 40326851
sorry meant to say it's a JS error not php error...
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 58

Accepted Solution

by:
Gary earned 1000 total points
ID: 40326856
Remove the return from the statement but you do have php code inside the js.
0
 
LVL 7

Author Comment

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

Expert Comment

by:leakim971
ID: 40326858
what is : $_GET[rackID]

That's smell PHP.
0
 
LVL 7

Author Comment

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

Expert Comment

by:leakim971
ID: 40326862
@GaryC123 is right, did you removed the return ?
0
 
LVL 7

Author Comment

by:Robert Saylor
ID: 40326863
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
ID: 40326865
<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
ID: 40326866
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 7

Author Closing Comment

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

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

770 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