一个大公司很有难度的面试题

lh19851111 2009-12-17 12:54:08
题目是这样的:
现在在画面上有一个list表,表里有N条数据,其中有一列是显示番号,还有一列是checkbox框。当点击提交按钮的时候,check相同的番号的checkbox框是否状态一样,如果不一样则报错。

例如
checkbox Number
true 1
true 1
false 1
true 2
true 2
. .
. .
. .
. .
. .
相同的番号 但是checkbox的状态不同都是true或者(都是false是不报错 只有不同的时候报错)
...全文
175 20 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
tider_ys 2009-12-17
  • 打赏
  • 举报
回复
高手,学习了
fengsky491 2009-12-17
  • 打赏
  • 举报
回复
请教你的hashtable是什么,是用Array吗
[Quote=引用 9 楼 yixianggao 的回复:]
引用 4 楼 lh19851111 的回复:
服你们了,2假高手。。。。

俺就是1号假高手,嘎嘎

如果使用 HashTable,代码会更简洁。
[/Quote]
shenshiluguo 2009-12-17
  • 打赏
  • 举报
回复
学习了
lovesiyile 2009-12-17
  • 打赏
  • 举报
回复
每天回帖即可获得10分可用分!
yixianggao 2009-12-17
  • 打赏
  • 举报
回复
学习 js 的关键在于弄清楚基于 prototype 的对象模型!
yixianggao 2009-12-17
  • 打赏
  • 举报
回复
Web 开发常用手册

JScript语言参考.rar
http://download.csdn.net/source/308916

DHTML参考手册.rar
http://download.csdn.net/source/308913

样式表中文手册.chm
http://download.csdn.net/source/304124
lh19851111 2009-12-17
  • 打赏
  • 举报
回复
虽然可能大家看不明白但是同样的功能也能够实现,不过也谢谢那位哥哥了 我马上给分
lh19851111 2009-12-17
  • 打赏
  • 举报
回复
呵呵 我写了个简单的方法给大家分享下

for(k=0; k<listBlock.rowCount; k++)
{
var Number = "Number";
var exteriorNo1 = listBlock.rowBlock[k].getItem(Number).getValue();
for(i=1;i<listBlock.rowCount;i++)
{
var exteriorNo2 = listBlock.rowBlock[i].getItem(LBL_EXTERIORNO).getValue();
if(!(exteriorNo1!=exteriorNo2))
{
var exteriorNo1checked = document.getElementsByName("HDN_CHK_SELECT")[k].value;
var exteriorNo2checked = document.getElementsByName("HDN_CHK_SELECT")[i].value;
if(exteriorNo1checked!=exteriorNo2checked)
{
listBlock.rowBlock[k].getItem(LBL_EXTERIORNO).setError(UtilClass.makeMessage(MSG_JSW1020,""));
PageClass.errFocus = "LBL_EXTERIORNO";
PageClass.errLine = k;
PageClass.error = true;
alert("is error!!!!!");
break;
}
}
}
q107770540 2009-12-17
  • 打赏
  • 举报
回复
基本功。。。
yixianggao 2009-12-17
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 lihui_shine 的回复:]
谁说没难度,我说还是有难度的

我不信yixianggao能在5分钟内完成
[/Quote]
呵呵,实现肯定超过 5 分钟,毕竟要一个一个字敲出来。

Hash,循环,判断,都是常用结构,属于基本功。
浪尖赏花 2009-12-17
  • 打赏
  • 举报
回复
谁说没难度,我说还是有难度的

我不信yixianggao能在5分钟内完成
yixianggao 2009-12-17
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 lh19851111 的回复:]
服你们了,2假高手。。。。
[/Quote]
俺就是1号假高手,嘎嘎

如果使用 HashTable,代码会更简洁。
lh19851111 2009-12-17
  • 打赏
  • 举报
回复
感谢楼上哥哥回帖 虽然我看不太明白吧 但是感谢一下 等等给你分啊
lh19851111 2009-12-17
  • 打赏
  • 举报
回复
不会直说嘛
yixianggao 2009-12-17
  • 打赏
  • 举报
回复
L@_@K

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
</head>

<body>
<table id="tbeTest">
<tr>
<th>CheckBox</th>
<th>Number</th>
</tr>
<tr>
<td><input type="checkbox" checked /></td>
<td>1</td>
</tr>
<tr>
<td><input type="checkbox" checked /></td>
<td>1</td>
</tr>
<tr>
<td><input type="checkbox" /></td>
<td>1</td>
</tr>
<tr>
<td><input type="checkbox" checked /></td>
<td>2</td>
</tr>
<tr>
<td><input type="checkbox" checked /></td>
<td>2</td>
</tr>
<tr>
<td><input type="checkbox" checked /></td>
<td>3</td>
</tr>
<tr>
<td><input type="checkbox" checked /></td>
<td>3</td>
</tr>
<tr>
<td><input type="checkbox" checked /></td>
<td>4</td>
</tr>
<tr>
<td><input type="checkbox" /></td>
<td>3</td>
</tr>
</table>
<script type="text/javascript">
<!--
function Element(key, value, rowInd) {
this.Key = key;
this.Value = value;
this.RowIndexes = new Array();
this.RowIndexes.push(rowInd);
}

Element.prototype.AddRowInd = function(rowInd) {
this.RowIndexes.push(rowInd);
};

var checker = {
List: {},
ErrorList: {},
AddElement: function(key, value, rowInd) {
if (this.List[key]) {
if (this.List[key].Value != value
&& this.ErrorList[key] == undefined) {
this.ErrorList[key] = this.List[key];
}
this.List[key].AddRowInd(rowInd);
}
else {
this.List[key] = new Element(key, value, rowInd);
}
},
ShowError: function() {
var msg = "";
for (var p in this.ErrorList)
{
msg += "Error Key: " + p + ", RowIndex: " + this.ErrorList[p].RowIndexes.join("; ") + "\n";
}
if (msg.length > 0)
alert(msg);
}
};

var tbe = document.getElementById("tbeTest");
var row;
for (var i=1, len=tbe.rows.length; i<len; i++)
{
row = tbe.rows[i];
checker.AddElement(row.cells[1].innerHTML, row.cells[0].firstChild.checked, i);
}

checker.ShowError();
//-->
</script>
</body>
</html>
Click_Me 2009-12-17
  • 打赏
  • 举报
回复

那个大公司 随着楼主 一起秀逗了...
lh19851111 2009-12-17
  • 打赏
  • 举报
回复
服你们了,2假高手。。。。
jol_boy 2009-12-17
  • 打赏
  • 举报
回复
没看出来~
lh19851111 2009-12-17
  • 打赏
  • 举报
回复
那倒是给个正解啊,用js啊
yixianggao 2009-12-17
  • 打赏
  • 举报
回复
真没看出有啥难度?!

87,997

社区成员

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

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