Solved

syntax error

Posted on 2014-09-16
12
183 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
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 250 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 6

Author Comment

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

Accepted Solution

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

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 6

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 6

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 6

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

932 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

13 Experts available now in Live!

Get 1:1 Help Now