Jump to content

Help with my assignment!


andrew_biggart

Recommended Posts

Ok so i am trying to design a simple guestbook. I have managed to get the code working finally and i can display the information no problem without styling it. But im now trying to get it diisplayed in a table and this is the where the problem start.

 

i want to display the information in the following table.

 

		<table style="width: 100%" cellspacing="0" cellpadding="0" class="cat">
			<tr>
				<td colspan="3" class="header"> </td>
			</tr>
			<tr>
				<td rowspan="2" class="logo" style="height: 40px; width: 40px;" valign="top">
				<img alt="Guestbook entry" src="Guesbook_Logo2.png" width="30" height="30" /></td>
				<td class="written">Written by : </td>
				<td class="writtenby">Name echoed here</td>
			</tr>
			<tr>
				<td class="subject" colspan="2">post echoed hear</td>
			</tr>
		</table>

 

this si my read.js file

 

<?php

//Set no caching

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");

header("Cache-Control: no-store, no-cache, must-revalidate");

header("Cache-Control: post-check=0, pre-check=0", false);

header("Pragma: no-cache");

?>

 

var guestbook;

window.addEvent('domready', function(){

guestbook = new GuestBook();

});

 

var GuestBook = new Class({

 

initialize: function(){

var req = new Request.JSON({

url: 'control.php?action=getPage',

onSuccess: this.success

}).send();

},

 

success: function(jArray){

jArray.each(function(post){

var post = new PostItem(post.id, post.name, post.comment);

post.display().inject($('commentList'));

}, this);

}

 

});

 

 

var PostItem = new Class({

 

initialize: function(id, name, comment){

this.id = id;

this.name = name;

this.comment = comment;

},

 

display: function(){

var cont = new Element('td',{

'class':'',

'id':'post'+this.id

});

var title = new Element('td',{

'class':'written',

'text':this.name + ' says...'

});

var comment = new Element('td',{

'class':'writtenby',

'text':this.comment

});

 

title.inject(cont);

comment.inject(cont);

return cont;

}

});

 

 

Cant someone please poin me in the right direction please?

 

 

Link to comment
Share on other sites

im now using this code and it is working to an extent, but i duont know how i can add exta fields so that th comment appears eblow the name.

 


<?php
//Set no caching
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
?> 

var guestbook;
window.addEvent('domready', function(){
guestbook = new GuestBook();
});

var GuestBook = new Class({

initialize: function(){
	var req = new Request.JSON({
		url: 'control.php?action=getPage',
		onSuccess: this.success
	}).send();
},

success: function(jArray){
	jArray.each(function(post){
		var post = new PostItem(post.id, post.name, post.comment);
		post.display().inject($('commentList'));
	}, this);
}

});


var PostItem = new Class({	

initialize: function(id, name, comment){
	this.id = id;
	this.name = name;
	this.comment = comment;
},

display: function(){
	var cont = new Element('tr',{
		'class':'',

	});

	var title = new Element('td',{
		'class':'written',
		'text':this.name + ' says...'
	});
	var comment = new Element('td',{
		'class':'writtenby',
		'text':this.comment
	});

	title.inject(cont);
	comment.inject(cont);
	return cont;
}
});

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.