PDA

View Full Version : missing ) after argument list ajax.updater



ksquared3
02-01-2011, 02:34 PM
This code is contained in an include. Maybe I've been looking too long, but the parenthesis is there. I'll appreciate any advice you have. Thanks!


<?php
$paintingBack=$paintingNumber-1;
$paintingNext=$paintingNumber+1;
if ($paintingBack < 1) {
$paintingBack = $paintingBack + 1;
}
?>
<a href="#" class='link' onFocus='if(this.blur)this.blur()' onclick="change_content('imagediv', '<img src='images/painting_<? echo $paintingBack; ?>.jpg'/>')"><img src='images/braceL.gif' alt='brace' width='20' height='11' valign='text-bottom'/></a>

djr33
02-01-2011, 10:34 PM
The SRC for your img tag uses single quotes, and this is within the string argument for the change_content() function.

You must escape these quotes using \' instead of just '.

ksquared3
02-01-2011, 10:41 PM
Thanks, djr33. I have tried that. Didn't work. Neither did many different combinations of delimiters and breaks. I may have to give up. My client is getting antsy. Of course, he doesn't care if the site has 56 pages instead of 6, but I do. Must.try.to.go.with.the.flow.

djr33
02-01-2011, 10:54 PM
There's no question that you must escape a symbol when it also denotes the end of a string (in a context like that). There may be other problems, but if you don't fix that, the code will never work and it should never work.
Once it's fixed, you can start trying to debug things again and you may even get a more meaningful error notice.

ksquared3
02-01-2011, 11:15 PM
OK then. I'll escape all ' within the string. Thanks.

ksquared3
02-02-2011, 12:13 AM
OK, done. The computed code =


<a href="" class='link' onFocus='if(this.blur)this.blur()' onclick="change_content('imagediv', '<img src=\'images/painting_2.jpg\'/>')"><img src='images/braceL.gif' alt='brace' width='20' height='11' valign='text-bottom'/></a>

error: File not found. !

ksquared3
02-02-2011, 12:28 AM
fyi: This is the line of code in prototype.js that doesn't like the string. lines #1530-31


this.body = this.method == 'post' ? (this.options.postBody || params) : null;
1531 this.transport.send(this.body);

djr33
02-02-2011, 12:54 AM
What file isn't found? I don't think the code you're using is causing that. Does this function work in other cases? Can you show us a working example?
I think this may be beyond my knowledge of Javascript, but someone else can probably help. The escaping is correct, so that's at least the first step done.

djr33
02-02-2011, 12:55 AM
What file isn't found? I don't think the code you're using is causing that. Does this function work in other cases? Can you show us a working example?
I think this may be beyond my knowledge of Javascript, but someone else can probably help. The escaping is correct, so that's at least the first step done.

ksquared3
02-03-2011, 11:36 PM
Sorry, it's taken me so long to get back to you. I was up for days, finally got it working without using this function. No matter what I did, the escape character, \ , was never recognized and I had to move on. Thanks very much for your help.

djr33
02-04-2011, 12:14 AM
Well I hope you found an alternative solution. If not, you could approach this very differently: create a function in the head section of your page and refer to it from these instances, rather than including so much content directly.

ksquared3
02-04-2011, 05:24 AM
That is exactly what I did. Now I'm finding that the functions (2) will not execute onclick. I just tried to attach the main files but php is not accepted. Here is the code for the functions which are declared in the <head>. Does anything strike you as odd? Thanks for your attention here!

[code]<script type="text/javascript">
var count;
var imageURL;
</script>
<script type="text/javascript">
function directionBack()
{
if (count > 1)
count = count - 1;
return count;
}
</script>
<script type="text/javascript">
function imageToDiv(count)
{
imageURL = "<img src=\'images/painting_\' + count + \'.jpg' />";
document.getElementById("imagediv").innerHTML = imageURL
return false;
}
</script>[code]

ksquared3
02-04-2011, 05:35 AM
Error message: functions "not defined"

ksquared3
02-04-2011, 06:35 AM
Functions are executing, no errors. I corrected the onBlur code, too. It looks like either count is not being decremented in directionBack() or imageToDiv is not replacing the html. These are the functions as they stand now.


<script type="text/javascript">
function directionBack()
{if (count > 1){
count = count - 1;
return count;
}}
</script>
<script type="text/javascript">
function imageToDiv(count) {
var imageURL = '<img src="images/painting_' + count + '.jpg" />';
document.getElementById("imagediv").innerHTML = imageURL;
return true;
}
</script>

ksquared3
02-04-2011, 09:43 AM
This problem has been solved. If anyone wants the code, just ask.