Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

paul.haenel

macrumors newbie
Original poster
Nov 4, 2008
2
0
Hi all,

im new to the iPhone dev kit for about a week not and i hit the first problem.

Im using and Edge-to-Edge list. The array data is set in the main.js inside the init funcation like:

list.object.setDataArray(array);

where array is in a format of [[row0label, row0value], [row1label, row1value],...] -> thsi array is been created from records which are been store in a DB.

The list gets displayed correctly, but now i want to add a link to a new view. So far i added a handler on the onlick event of the ListRowTemplate insidide the funcation i have the following:

alert(document.getElementById('listRowTemplate').value);

This always displays zero :s and i dont know why :S

Any help appreciated.
Thanks guys.
 

jnic

macrumors 6502a
Oct 24, 2008
567
0
Cambridge
main.js

[...]

list.object.setDataArray(array);

[...]

onClick event

[...]

alert(document.getElementById('listRowTemplate').value);

The code you've posted appears to be JavaScript rather than Objective-C. So yes, a little more explanation would help!
 

paul.haenel

macrumors newbie
Original poster
Nov 4, 2008
2
0
Yes I'm developing a webapp in javascript.

Im using a dynamic edge-to-edge list. The list gets displayed correctly :). (see picture :)).

I added a onClick event to the listRowTemplate which just alert's the value been pressed:

alert(document.getElementById('listRowTemplate').value);

If i press / click on item one zero is displayed.
If i press / click on item two also zero is displayed.
If i press / click on item three ALSO zero is displayed.

How do i get the correct value of the pressed value which has been press.

I want to display:

If i press / click on item one: "one been pressed".
if i press / click on item two : "two been pressed".
...

Anymore question please ask!!
 

Attachments

  • Picture 1.png
    Picture 1.png
    12.1 KB · Views: 90

jnic

macrumors 6502a
Oct 24, 2008
567
0
Cambridge
Yes I'm developing a webapp in javascript.

Ah, understood. I'm afraid this forum is for iPhone development (Objective-C) using Apple's SDK, so you're unlikely to find much help here with JavaScript since most of us are not web developers.

You might have more luck here: http://www.webmasterworld.com/javascript/

Re. your code; what value are you trying to retrieve? if you want the actual content of the cell you might want to try innerHTML since the element itself is unlikely to have a value.
 

jnic

macrumors 6502a
Oct 24, 2008
567
0
Cambridge
Ah, I see, you're after the index of the cell in the table. JavaScript provides the cellIndex method for just this purpose:

Code:
<td id="cell1" onclick="index(this);">Item 1</td>
<td id="cell2" onclick="index(this);">Item 2</td>
etc.

Code:
<script type="text/javascript">
function index(element) {
    alert("Cell index is " + element.cellIndex);
}
</script>
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.