2016-08-30 6 views
0

내 HTML이 양식을 가지고 (크롬에 확인) 파이어 폭스 및 IE에 아무 것도 반환하지 않습니다. 다음과 같이 값을 얻을 때 :HTML 양식

vote = self.request.get('vote') 

"up"또는 "down"중 하나가됩니다.

하지만 IE와 Firefox에서 동일한 작업을 수행 할 때 빈 문자열이 표시됩니다.

(HTML의 if/else 문은 사용자가 아직 특정 콘텐츠에 투표하지 않은 경우 아이콘이 회색으로 표시된다는 것을 의미합니다. 그렇지 않으면 검은 색입니다).

Jinja2를 템플릿 엔진으로 사용하는 Google App Engine에서 작업하고 있습니다.

+0
+0

예, 작동합니다. 눌렀을 때 양식을 제출하는 아이콘입니다. 그러나 vote = "up"또는 vote = "down"이 아닌 vote = ""가 있어야합니다. –

답변

0

시도해보십시오.

<form action="/vcontent?topic={{ topic.name }}" method="post"> 
    {% if user and user.email in c.users_up %} 
    <input type="image" src="icons/thumb-up.png" alt="Up!" name = "vote" value = "up" /> 
    {% else %} 
    <input type="image" src="icons/thumb-up_gray.png" alt="Up!" name = "vote" value = "up" /> 
    {% endif %} 
    <input type="hidden" name = "vote" value = "up"/> 
    <input name= "content_key" type="hidden" value="{{ c.key.urlsafe() }}"> 
</form> 
<form action="/vcontent?topic={{ topic.name }}" method="post"> 
    {% if user and user.email in c.users_down %} 
    &nbsp;<input type="image" src="icons/thumb-down.png" alt="Down!" name = "vote" value = "down" /> 
    {% else %} 
    &nbsp;<input type="image" src="icons/thumb-down_gray.png" alt="Down!" name = "vote" value = "down" /> 
    {% endif %} 
    <input type="hidden" name = "vote" value = "down"/> 
    <input name= "content_key" type="hidden" value="{{ c.key.urlsafe() }}"> 
</form> 

:

<style>button {height:32px; width:32px;}</style> 

<form action="/vcontent?topic={{ topic.name }}" method="post"> 
    {% if user and user.email in c.users_up %} 
    <button type="submit" style="background: url(icons/thumb-up.png)" title="Up!" name="vote" value="up" /> 
    {% else %} 
    <button type="submit" style="background: url(icons/thumb-up_gray.png)" title="Up!" name="vote" value="up" /> 
    {% endif %} 
    {% if user and user.email in c.users_down %} 
    &nbsp;<button type="submit" style="background: url(icons/thumb-down.png)" title="Down!" name="vote" value="down" /> 
    {% else %} 
    &nbsp;<button type="submit" style="background: url(icons/thumb-down_gray.png)" title="Down!" name="vote" value="down" /> 
    {% endif %} 
    <input name= "content_key" type="hidden" value="{{ c.key.urlsafe() }}"> 
</form> 
+0

감사! 작동하지만, 페이지의 아이콘을 엉망으로 만들었습니다. CSS로 크기를 조정하려고했지만 작동하지 않았습니다. 단추 대신 이미지로 작업하게하는 방법이 없습니까? –

0

내가 누구든지이 작업을 수행 할 수 있습니다, 나는 내 솔루션을 게시하도록하겠습니다 그것을 밖으로 일을 생각 좋아, 그 코드의 대신 이미지를 사용하는 버튼을 사용하여 기본적으로 첫 번째 부분이 upvote를 관리하고 두 번째 부분이 downvote를 관리하는 코드를 두 배로 늘 렸습니다. 아이콘을 클릭하면 투표 값이 숨김으로 반환됩니다. 코드를 두 번 입력하는 것이 필연적이라고 생각합니다. 그렇지 않으면 눌린 아이콘에 따라 숨겨진 값의 값을 설정할 수 없습니다.