The relevant code causing the problem seems to be this from my view:
<input type="checkbox" id=<%= "#{a[0]}#{ndx}" -%> class="toggle" />
<label for=<%= "#{a[0]}#{ndx}" -%> class="popup-label">
This throws the following error in the Heroku logs:
SyntaxError - /app/views/index.erb:25: syntax error, unexpected ')'
2017-03-17T06:30:26.877056+00:00 app[web.1]: ...buf.concat(( "#{a[0]}#{ndx}" -).to_s); #_out_buf.concat " cl...
2017-03-17T06:30:26.877061+00:00 app[web.1]: /app/views/index.erb:26: syntax error, unexpected ')'
2017-03-17T06:30:26.877057+00:00 app[web.1]: ... ^
2017-03-17T06:30:26.877061+00:00 app[web.1]: ...buf.concat(( "#{a[0]}#{ndx}" -).to_s); #_out_buf.concat " cl...
I initially thought it might be the difference between using WEBrick and Puma, but I swapped them and found no difference. Suggestions?
Please try the below
<input type="checkbox" id="<%= a[0].to_s + ndx.to_s %>" class="toggle" />
<label for="<%= a[0].to_s + ndx.to_s %>" class="popup-label">
Related
Recently moved a classic ASP application from windows 2003 to windows 2008 R2. After a lot of work, everything is functioning the same except for one thing. On the search results and category pages, I get the following error when trying to go to the next page of results:
Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'Left'
/incpages/SearchResults.asp, line 1372
The code relative to this is here:
<form method="POST" name="MainForm" id="MainForm" action="/SearchResults.asp">
Page <input type="text" value="<%=ThisPageNum%>" size="3" name="Page" id="Page_SR" maxlength="4"> of <%=TotalPagesNum%>
<% Dim pageURL
pageURL = Request.ServerVariables("HTTP_X_ORIGINAL_URL")
%>
<%If ((InStr(LCase(Request.ServerVariables("HTTP_X_ORIGINAL_URL")),"/searchresults.asp")) > 0) Then%>
<%If ThisPageNum <> TotalPagesNum Then %>
<%If (ThisPageNum = "1") Then %>
<input type="image" border="0" name="btnNextPage" src="<%=SEOImage(Config_ImagesFolder & "/buttons/btn_nextpage.gif")%>" onClick="document.getElementById('Page_SR').value=<%=(ThisPageNum + 1)%>">
<%Else%>
<img src="<%=SEOImage(Config_ImagesFolder & "/buttons/btn_nextpage.gif")%>" border="0" name="btnNextPage" />
<%End If %>
<%End If %>
</form>
So when I go here: /SearchResults.asp?cat=80&page=1 the results show up fine. If I go here: /SearchResults.asp?cat=80&page=2 or any other page within TotalPagesNum, I get that error.
I haven't been able to figure out why it stopped working after the switch
I want to set one image in image tag using RoR. That image path is fetched from DB and it has to set inside image tag.I have done some coding but unable to display that image.It also showing the following error.
Error:
SyntaxError in Homes#home
Showing C:/Site/swargadwara_puri/app/views/homes/home.html.erb where line #209 raised:
C:/Site/swargadwara_puri/app/views/homes/home.html.erb:209: syntax error, unexpected $undefined
...",:height => "140",:border => \'0\',:class =>\'borderblackdi...
... ^
C:/Site/swargadwara_puri/app/views/homes/home.html.erb:223: syntax error, unexpected ')', expecting keyword_end
'); else
^
Extracted source (around line #209):
206: </div>
207: <div class="tpaddingdiv1">
208: <div class="col-md-4">
209: <div class="text-center bpaddingdiv1"><% image_tag("<%= #hcsy.D_Photo %>",:height => "140",:border => '0',:class =>'borderblackdiv' ) %></div>
210: <div class="fontweightbolddiv fontssizediv3 text-center bpaddingdiv1">Deceased Photo</div>
211: </div>
212: <div class="col-md-4">
Please check my below line.
<div class="text-center bpaddingdiv1"><% image_tag("<%= #hcsy.D_Photo %>",:height => "140",:border => '0',:class =>'borderblackdiv' ) %></div>
Please help me to resolve this error and display this image successfully.
Try this,
<div class="text-center bpaddingdiv1"><%= image_tag("#{#hcsy.D_Photo}",:height => "140",:border => '0',:class =>'borderblackdiv' ) %></div>
Changes are: <% image_tag... to <%= image_tag and "<%= #hcsy.D_Photo %>" to "#{#hcsy.D_Photo}"
Edited
change "<%= #hcsy.D_Photo %>" to "/#{#hcsy.D_Photo}"
I have the following in a .js.erb file, being returned after a form being submitted with remote: true.
create.js.erb
$("#flash-notices").html(" <%= escape_javascript(render(partial: "/shared/flash_messages", locals: { form_errors: #artist.errors.full_messages } )) %> ");
$("#flash-notices").fadeIn(300).delay(3000).fadeOut(300);
...
However, what is being returned to the browser is this:
<textarea data-type="text/javascript" response-code="200">
$("#flash-notices").html(" <ul>\n <div class=\"alert alert-success\">\n <li class=\"alert-item\">Artwork saved<\/li>\n <\/div>\n <\/ul>\n ");
$("#flash-notices").fadeIn(300).delay(3000).fadeOut(300);
...
</textarea>
How can I stop the first level of JS escaping which is stopping the jQuery from executing?
I'm writing a simple Sinatra app but having issues having <input type="file" multiple /> not making Rack throw a NoMethodError: undefined method 'bytesize' for (Hash) while reading the files.
The form is written like so:
<form action="/upload" enctype="multipart/form-data" method="post">
<input type="file" name="images[]" multiple />
</form>
But the receiving end throws the mentioned error, before any of my code executes, that is, Rack is not parsing correctly the input[name=images]. Am I sending the form incorrectly? If I drop the brackets [], then only the last file (of many) is sent, but I feel like I might be missing something...
Just to clarify: this is Sinatra v1.4.3 and Rack v1.5.2, the latter being the one throwing the exception. Full backtrace here.
The only thing that puts me off here is that you don't use the POST method – maybe your issue has to do with that. Anyway, the following code works perfectly for me. I hope this will give you a hint how to fix your code.
require 'sinatra'
get '/' do
<<-HTML
<html>
<head><title>Multi file upload</title></head>
<body>
<form action="/upload" method="post" enctype="multipart/form-data">
<input type="file" name="images[]" multiple />
<input type="submit" />
</form>
</body>
</html>
HTML
end
post '/upload' do
content_type :text
res = "I received the following files:\n"
res << params['images'].map{|f| f[:filename] }.join("\n")
res
end
I followed these instructions here: http://w3schools.com/razor/razor_example.asp
NOTE: I'm using Web Matrix
The example said to do this:
#
{
var imagePath;
if( Request["Choice"] != null)
{imagePath="images\" + Request["Choice"];}
}
<!DOCTYPE html>
<html>
<body>
<h1>Display Images</h1>
<form method="post" action="">
<div>
I want to see:
<select name="Choice">
<option value="Photo1.jpg">Photo 1</option>
<option value="Photo2.jpg">Photo 2</option>
<option value="Photo3.jpg">Photo 3</option>
</select>
<input type="submit" value="Submit" />
</div>
<div style="padding:10px;">
#if(imagePath != "")
{<img src="#imagePath" alt="Sample" />}
</div>
</form>
</body>
</html>
And all i get this this error:
Does anything have to be setup to accept # { being on seperate lines?
Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource
required to service this request. Please review the following
specific parse error details and modify your source file appropriately.
Parser Error Message: A space or line break was encountered after
the "#" character. Only valid identifiers, keywords, comments,
"(" and "{" are valid at the start of a code block and they must
occur immediately following "#" with no space in between.
Source Error:
Line 1: #
Line 2: {
Line 3: var imagePath;
Source File: /Page.cshtml Line: 1
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
If I put them on the same line, i get this error:
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup.
Source Error:
Line 1: #{
Line 2: var imagePath;
Line 3: if( Request["Choice"] != null)
Source File: /Page.cshtml Line: 1
I don't know whats wrong.
Some people will stumble across this answer with just copying code samples from jquery.com into a razor file. For example I was testing something out and got the error from a long javascript variable value a regular expression specifically.
emailRegex = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+##[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,
Notice the ## , I had to add the second # to escape .... otherwise I get the error above and thus a google search shows me this stackoverflow page in the top result. So while this does not directly answer the question, I'm quite sure it could help someone else.
Here's how to fix the couple of errors in your code:
#{
var imagePath = "";
if(Request["Choice"] != null) {
imagePath = "images/" + Request["Choice"];
}
}
<!DOCTYPE html>
<html>
<body>
<h1>Display Images</h1>
<form method="post" action="">
<div>
I want to see:
<select name="Choice">
<option value="Photo1.jpg">Photo 1</option>
<option value="Photo2.jpg">Photo 2</option>
<option value="Photo3.jpg">Photo 3</option>
</select>
<input type="submit" value="Submit" />
</div>
<div style="padding:10px;">
#if(imagePath != "") {
<img src="#imagePath" alt="Sample" />
}
</div>
</form>
</body>
</html>
You need to remove line break after # character.change you code like this
#{
var imagePath;
////other things..
here is a good syntax reference for you http://haacked.com/archive/2011/01/06/razor-syntax-quick-reference.aspx
and you need to change these lines too,
#{if(imagePath != "")
<img src="#imagePath" alt="Sample" />
}
Your code is wrong at var imagePath;
You can not declare with var without assigning a value.
Just change it to:
var imagePath = "";
or
string imagePath;