如何从 Dashcode 中的圆角矩形列表获取行值?

发布于 12-25 14:46 字数 913 浏览 4 评论 0原文

我是 dashcode 的新手,并尝试使用它为 iphone 构建一个简单的网络应用程序。我的主要目标是拥有一个矩形列表(我使用了“圆角矩形列表”)。它是一个静态列表,具有三行。我想要的是当用户单击任何行时打开一个网站,并且每行都有不同的 URL。我能够添加一个包含三个静态行的圆角矩形列表,例如

对象 ID 为“列表”

第 1 行--标签-“礼品卡”,值-“http://www.abcxyz.com/giftcard”

第 2 行- - 标签 - “玩具”,值 - “http://www.abcxyz.com/toys”

第 3 行 - 标签 - “自行车”,值 - “http://www.abcxyz.com/bikes”

我添加了 onclick 甚至调用 java 脚本函数,如下所示,

function myButtonPressHandler(event)
{

   var websiteURL = "http://www.abcxyz.com/giftcard";
   location = websiteURL;

}

当用户单击时,上面的代码会打开相同的 URL“http://www.abcxyz.com/giftcard”三个按钮中的任何一个,但我想要的是在运行时获取每个子节点的值(这将是它们各自的 URL)并使用 location = WebsiteURL 打开它,如下所示(对我不起作用:( -

function myButtonPressHandler(event)
{

   var websiteURL = document.getElementById("list").children;
   var WebURL = websiteURL[???].value;
   location = WebURL;

}

Any帮助将是赞赏。 谢谢

I am new to dashcode and trying to build a simple web app for iphone using it. My primary aim is to have a Rectangular List (I have used the "Rounded rectangle list"). It is a static list and has three rows. What I want is a website to open when user clicks on any of the row, and each row would have a different URL. I was able to add a Rounded rectangle list with three static rows like

The object ID is "list"

Row 1-- Label- "Gift Cards" , Value - "http://www.abcxyz.com/giftcard"

Row 2-- Label- "Toys" , Value - "http://www.abcxyz.com/toys"

Row 3-- Label- "Bikes" , Value - "http://www.abcxyz.com/bikes"

i added onclick even to call a java script function like below

function myButtonPressHandler(event)
{

   var websiteURL = "http://www.abcxyz.com/giftcard";
   location = websiteURL;

}

the above code opens the same URL "http://www.abcxyz.com/giftcard" when the user clicks on any of the three buttons, but what I want is to fetch the value of each child node (which would be their respective URLs) at runtime and open it using location = WebsiteURL something like below (did'nt work for me :( -

function myButtonPressHandler(event)
{

   var websiteURL = document.getElementById("list").children;
   var WebURL = websiteURL[???].value;
   location = WebURL;

}

Any help would be appreciated.
Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如梦初醒的夏天2025-01-01 14:46:40

好吧...所以想出了我自己的答案。圆角矩形列表实际上是一个多维数组。因此,要获取每行的值(即 Http URL)并在触摸/点击/按下行时在浏览器上打开它们,如下所示。

function buttonpresshandler(event)
{
   // Insert Code Here
   var list = document.getElementById("list").object;
   var selectedObjects = list.selectedObjects();      
   //Open webpage with the value of each label
   location = selectedObjects[0][1];
}

欢呼!

OK ... so figured out my own answer. The Rounded Rectangular list is actually a multidimensional array. so to get the value of each of the rows i.e. the Http URLs and open them on the browser when the rows were touched/tapped/pressed is as below.

function buttonpresshandler(event)
{
   // Insert Code Here
   var list = document.getElementById("list").object;
   var selectedObjects = list.selectedObjects();      
   //Open webpage with the value of each label
   location = selectedObjects[0][1];
}

Hurray!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文