Best way to display news from DB in jsp
-
-
Hello, what is best way to display news in jsp webpage. With asp i was using repeater, but in jsp i don't know how to. I also want to add buttons to each news so i could edit and delete it. For any kind of help i would be thankful. Best regards
-
Reading the data from the DB is one part. Displaying the data another. To add some button shouldn't be that difficult. so which part is the problem? regards Torsten
I never finish anyth...
Using div and dynamically creating it with for loop would be the way i will do it. If you have any better idea with displaying it i would be thankful. Reading and adding buttons is not problems. I was just looking for display. How to put id in session via javascript or using jsp code block? function for getting div id:
function getParent(el, parentTagName){
var obj = el;
while(obj.tagName !== parentTagName){
obj = obj.parentNode;
}alert(obj.id);
}
html code looks like this:
Thanks
modified on Friday, April 29, 2011 11:35 AM
-
Using div and dynamically creating it with for loop would be the way i will do it. If you have any better idea with displaying it i would be thankful. Reading and adding buttons is not problems. I was just looking for display. How to put id in session via javascript or using jsp code block? function for getting div id:
function getParent(el, parentTagName){
var obj = el;
while(obj.tagName !== parentTagName){
obj = obj.parentNode;
}alert(obj.id);
}
html code looks like this:
Thanks
modified on Friday, April 29, 2011 11:35 AM
I would go about this differently with your javascript. Since you know the iterations you've done (using your for loop), there would be no reason to loop through the page elements testing for equality. You should change the onclick function summary to include the ID you created for your div, e.g.:
<div id="0">
<form>
<input type="submit" target="pr" value="Go" onclick="getParent(this, 0)">
</form>
</div>(although I have to admit, I don't understand the purpose of your getParent function. It would make more sense to have the onclick of that button post a form up for processing, or kick off an AJAX request to add/remove a news item). Hope this helps, feel free to ask some targeted follow-up questions! Cheers!