JavaScript类型转换的问题

sequanyining 2010-07-09 10:39:26
<script type="text/javascript">
function a(count)
{
(count).toString();
alert(typeof(count));
this.location.href = "editServlet?count"=count;
this.forms[0].submit();
}
</script>


<!--页面-->
<td width="100" class="hh" align="center" height="22">
<input type="text" name="count" size="5" value="<%=item.getCount()%>" onblur="a(<%=item.getCount()%>)"/>
</td>

传递过来的count在java里是整形,alert(typeof(count))后,输出地是“number”类型,然后报错 : 不能给 '[string]' 赋值,也就是number转String没成功,请问应该怎么把整形给转成String呢?还是我别的地方写错了,大家帮我看看,谢谢了
...全文
100 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
zabcd117 2010-07-12
  • 打赏
  • 举报
回复
this.location.href = "editServlet?count"+count;
txyly998 2010-07-11
  • 打赏
  • 举报
回复
应该不用转换,因为http请求传输的数据全部都是字符串啊
一切为了你 2010-07-10
  • 打赏
  • 举报
回复

..........
this.location.href = "editServlet?count="+count.ToString();
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 bancxc 的回复:]
引用 1 楼 bancxc 的回复:

我猜你是想this.location.href = "editServlet?count="+count;
[/Quote]
1、2楼的头像,坏笑的样子,很搞笑啊
licip 2010-07-09
  • 打赏
  • 举报
回复
这样写才对,this.location.href = "editServlet?count="+count;
qq43695548 2010-07-09
  • 打赏
  • 举报
回复
this.location.href = "editServlet?count="+count;

就这一句行了,其他什么类型转换不要你去管
count可以是数字,可以是字符,bool,null想是什么都没问题
yudoggy 2010-07-09
  • 打赏
  • 举报
回复
就直接用+就可以 number会自动转换成string

如果心里实在觉得不舒服就手动转一下

"editServlet?count="+count.toString();
sequanyining 2010-07-09
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 bancxc 的回复:]
引用 1 楼 bancxc 的回复:

我猜你是想this.location.href = "editServlet?count="+count;
[/Quote]
我这里确实马虎写错了 请问我的类型转换对吗? 还是number类型 number怎么转String呢?
bancxc 2010-07-09
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 bancxc 的回复:]

[/Quote]我猜你是想this.location.href = "editServlet?count="+count;
bancxc 2010-07-09
  • 打赏
  • 举报
回复
this.location.href = "editServlet?count"=count;

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧