Ok i have this function what it does is takes the value of id time, user, title, and bodytext.
Function to insert into sql.
function getblogpost() {
var date = $('#time').text();
var user = $('#user').text();
var title = $('#title').text();
var textbody = $('#bodytext').text();
var postid = $('#pid').text();
dbsql.transaction(
function(transaction) {
transaction.executeSql(
'INSERT INTO blogpost (postid, date, user, title, textbody) VALUES (?, ?, ?, ?, ?);',
[postid, date, user, title, textbody],
function(){
},
errorHandler
);
}
);
return false;
}
And this would be the html that the above function works with.
<div id="main">
<div id="time">some text..</div>
<div id="user">some text..</div>
<div id="title">some text..</div>
<div id="bodytext">some text..</div>
<div id="pid">some text..</div>
</div>
<div id="main">
<div id="time">some text..</div>
<div id="user">some text..</div>
<div id="title">some text..</div>
<div id="bodytext">some text..</div>
<div id="pid">some text..</div>
</div>
<div id="main">
<div id="time">some text..</div>
<div id="user">some text..</div>
<div id="title">some text..</div>
<div id="bodytext">some text..</div>
<div id="pid">some text..</div>
</div>
The problem im having is that i dont know how to repeat one function for every div named main. Right now it only does it for the first main div but does now move onto the next main div.
What could be the best way to do this?