Solved

syntax error

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

Author Comment

by:Robert Saylor
ID: 40326851
sorry meant to say it's a JS error not php error...
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
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…

730 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