如何动态更改HTML表中的数据

时间:2010-10-23 14:20:55

标签: iphone objective-c xcode dynamic-data html-table

我有一个存储在字符串中的html标签,我想加载具有我通过程序动态给出的属性的表...

如何搜索html行和列的特定标记,并将数据添加到属性...

任何帮助表示赞赏......

提前致谢......

3 个答案:

答案 0 :(得分:1)

指定HTML标记的ID或类名,然后使用javascript或DOM更新它。 例如:

HTML code:

     

Javascript代码:

document.getElementByid(“tab1”)。value = Box1中的文字
document.getElementByid(“tab2”)。value = Box2中的文本

答案 1 :(得分:1)

嗯,我显然无法评论,所以这里是对Noddy Cha答案的更详细解释。

获取值:

NSString * textBox1Value = [myWebView stringByEvaluatingJavaScriptFromString:@"document.getElementByid(\"tab1\").value"];

NSString * textBox2Value = [myWebView stringByEvaluatingJavaScriptFromString:@"document.getElementByid(\"tab2\").value"];

设置值:

NSString * ignoredString1 = [myWebView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"document.getElementByid(\"tab1\").value = \"%@\"", textBox1Value]];

NSString * ignoredString2 = [myWebView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"document.getElementByid(\"tab2\").value = \"%@\"", textBox2Value]];

希望这有帮助。

答案 2 :(得分:-1)

我首先将html标签复制到字符串中,然后每当我想要更新日期......

然后最终iam将动态html显示在Web视图上以验证它....

相关问题