首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >发送反馈表

发送反馈表
EN

Stack Overflow用户
提问于 2015-12-24 11:07:50
回答 1查看 130关注 0票数 0

我有这张表格

对于明星有5张图片,点击设置为functionstar1,functionstar2等.这会改变图像的url (有2个url star1.png(黄色)和star2.png(白色))。这是控制星星的剧本:

代码语言:javascript
复制
<script>function functionStar1() {
document.getElementById('star1').src = "star1.png";
document.getElementById('star2').src = "star0.png";
document.getElementById('star3').src = "star0.png";
document.getElementById('star4').src = "star0.png";
document.getElementById('star5').src = "star0.png";
}
function functionStar2() {
document.getElementById('star1').src = "star1.png";
document.getElementById('star2').src = "star1.png";
document.getElementById('star3').src = "star0.png";
document.getElementById('star4').src = "star0.png";
document.getElementById('star5').src = "star0.png";
}
function functionStar3() {
document.getElementById('star1').src = "star1.png";
document.getElementById('star2').src = "star1.png";
document.getElementById('star3').src = "star1.png";
document.getElementById('star4').src = "star0.png";
document.getElementById('star5').src = "star0.png";
}
function functionStar4() {
document.getElementById('star1').src = "star1.png";
document.getElementById('star2').src = "star1.png";
document.getElementById('star3').src = "star1.png";
document.getElementById('star4').src = "star1.png";
document.getElementById('star5').src = "star0.png";
}
function functionStar5() {
document.getElementById('star1').src = "star1.png";
document.getElementById('star2').src = "star1.png";
document.getElementById('star3').src = "star1.png";
document.getElementById('star4').src = "star1.png";
document.getElementById('star5').src = "star1.png";
}</script>

我使用javascript发送信息,因为我需要使用以下脚本的星号的url:

代码语言:javascript
复制
<script>var password;
var titolo;
var feedback;
var valutazione;
var url;
function open(){
password = document.getElementById("password").value;
titolo = document.getElementById("titolo").value;
feedback = document.getElementById("feedback").value;
if (document.getElementById('star5').src == 'http://www.***.eu/star1.png') {
    valutazione = 'Eccellente';
} else if (document.getElementById('star4').src ==  
'http://www.***.eu/star1.png'){
    valutazione = 'Discreto';
}else if (document.getElementById('star3').src ==     
'http://www.***.eu/star1.png'){
    valutazione = 'Sufficiente';
}else if (document.getElementById('star2').src ==  
'http://www.***.eu/star1.png'){
    valutazione = 'Non sufficiente';
} else {
    valutazione = 'Pessimo';
}
url = 'http://www.***.eu/input.php?password=' + password + '&titolo=' +   
titolo + '&feedback=' + feedback + '&valutazione=' + valutazione;
document.getElementById("buttonhref").href = url;
}
setInterval(open, 10)</script>

问题是,它发送的<textarea>文本没有\n。是否有一种方法可以使用javascript或更好地使用\n来获取文本,是否有一种方法可以在没有javascript的情况下发送星图的url?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-12-24 11:31:36

如果您不想使用Javascript发送数据,uou可以设置一个隐藏值,该值将根据星号的数量进行更新,然后在表单提交之后进行处理。

代码语言:javascript
复制
<input type="hidden" name="stars" value="5" id="stars-val" />

<script>
  function updateStarValue(starNum){ // star num is 1,2,3,4,5
  document.getElementByID("stars-val").val = starNum;
  }
</script>

然后在每颗星星上,onclick=updateStarValue(2)等。

否则,使用preg_replace将换行符更改为

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34451822

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档