Hi.
I'm looking for a way to get the currently selected id from a tag element. I'm building an iPhone Bible app and as a way for the user to see where he is I extract the title and verse reference into a label. I can extract the title just fine but I need to get the numbers like '1:4' from the 'bs' tag as well. I'm thinking I need a function that loops through all the 'bs' tags and displays the one just selected, rather than having to write document.getElementsByTagName('bs')[0, 1, 2, 3 etc].innerText; a hundred times, but just what does it look like?
This is what my tags look like. I've also included a function I wrote. It gets all the ids and displays them one at a time in an alert panel. Naturally that is not what I want, but it's a start. Hopefully someone can help me out here:
I'm looking for a way to get the currently selected id from a tag element. I'm building an iPhone Bible app and as a way for the user to see where he is I extract the title and verse reference into a label. I can extract the title just fine but I need to get the numbers like '1:4' from the 'bs' tag as well. I'm thinking I need a function that loops through all the 'bs' tags and displays the one just selected, rather than having to write document.getElementsByTagName('bs')[0, 1, 2, 3 etc].innerText; a hundred times, but just what does it look like?
This is what my tags look like. I've also included a function I wrote. It gets all the ids and displays them one at a time in an alert panel. Naturally that is not what I want, but it's a start. Hopefully someone can help me out here:
Code:
function getCurrentId(what) {
var getId= document.getElementsByTagName('bs');
for (i=0; i<getId.length; i++) {
alert(getId[i]);
}
}
<bs id="1:4" onClick="getCurrentId(this);">
<b> 4</b></bs>
<vs id="vs4">“Is it the time for YOU yourselves to dwell in YOUR paneled houses,
while this house is waste?
</vs>
<bs id="1:5" onClick="getCurrentId(this);">
<b> 5</b></bs>
<vs id="vs5">And now this is what Jehovah of armies has said, ‘Set YOUR heart upon YOUR ways.
</vs>
<bs id="1:6" onClick="getCurrentId(this);">
<b> 6</b></bs>
<vs id="vs6">YOU have sown much seed, but there is a bringing of little in.
There is an eating, but it is not to satisfaction.
There is a drinking, but not to the point of getting intoxicated. There is a putting on of clothes, but it is not with anyone’s getting warm; and he that is hiring himself out is hiring himself out for a bag having holes.’”
</vs>