Solved

syntax error

Posted on 2014-09-16
12
187 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 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 7

Author Comment

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

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

688 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