[eluser]zyddee[/eluser]
Hello
Im trying to make an post validation with use of ajax.
But when i run and test it i get the error:
element has no properties
http://85.197.152.80/ci_partysmart/stati...ototype.js
Line 3484
View
Code:
<div id='mainDiv' class='newsDiv'>
<div class='newsHeader'>
<span class='Title'><?=$page['title']?></span>
<span class='newsTime'></span>
</div> <!-- END newsHeader -->
<div class='newsContent'>
<!-- [ G Ä S T B O K ][ new-post ] -->
<p>
<?/*
=form_open('guestbook');
onSubmit='CheckCommentForm("output","guestbook/gb_validatePost");
*/?>
<form id='AddGBCommentForm' method='post'>
<div class='comment'>
<table class='tform'>
<!--row-->
<tr> <td><b>Namn</b> (obligatoriskt)</td> <td><b>E-mail</b> (visas inte)</td> <td><b>Hemsida/Blog</b> (visas inte)</td> </tr>
<!--row-->
<tr>
<td><input type='text' name='author' id='author' value='<?=$this->validation->author;?>' class='form' /></td>
<td><input type='text' name='email' id='email' value='<?=$this->validation->email;?>' class='form' /></td>
<td><input type='text' name='page' id='page' value='<?=$this->validation->page;?>' class='form' /></td>
</tr>
<!--row-->
<tr> <td colspan='3'><b>Kommentar</b></td> </tr>
<!--row-->
<tr>
<td colspan='3'><textarea name='text' rows='5' cols='75' class='form'><?=$this->validation->text;?></textarea></td>
</tr>
</table>
<input type='hidden' name='ip' id='ip' value='<?=$_SERVER['REMOTE_ADDR'];?>' />
<input type='hidden' name='postid' id='postid' value='-1' />
<input type='submit' value='Skicka' class='submit' />
</div> <!-- END Add Comment Div -->
</form>
<?=$formsuccess;?>
<div id='output'><?=$this->validation->error_string; ?></div>
</p>
<!-- END [ G Ä S T B O K ][ new-post ] -->
</div> <!-- END newsContent -->
<div class='newsBottom'>
</div> <!-- END newsBottom -->
</div> <!-- END newsDiv -->
<!-- [ G Ä S T B O K ][ view-posts ] -->
<div id='guestbookDiv' style='float: left;' class='newsDiv'>
<?=$views['guestbook']?>
</div> <!-- END guestbookDiv -->
<!-- END [ G Ä S T B O K ][ view-posts ] -->
Controller
Code:
function gb_validatePost()
{
$this->validation->set_error_delimiters('<div class="error">', '</div>');
$this->validation->error_string = null;
$this->validation->set_message('gb_validateIP', 'You have to wait a while before posting again.');
// -INPUTS------------------------------
// author, email , page , text , postid , ip
$rules['author'] = 'required|min_length[3]|max_length[30]';
$rules['email'] = 'required|valid_email';
$rules['text'] = 'required|min_length[6]|max_length[500]';
$rules['postid'] = 'required';
$rules['ip'] = 'callback_gb_validateIP';
$rules['page'] = 'prep_url';
$this->validation->set_rules($rules);
$fields['author'] = 'author';
$fields['email'] = 'email';
$fields['text'] = 'text';
$fields['page'] = 'page';
$fields['postid'] = 'postid';
$fields['ip'] = 'ip';
$this->validation->set_fields($fields);
if ( !$path = $this->uri->segment(1) )
{
$path = "guestbook";
}
if ( ($this->validation->run() == FALSE) && ($this->template['page'] = $this->page->get($path)) )
{
$this->template['formsuccess'] = '';
}
else if($this->template['page'] = $this->page->get($path))
{
$this->post_gb_post();
$this->template['formsuccess'] = 'Ditt inlägg postades felfritt !';
$this->posts->getComments( $this->input->post('postid') );
}
}
Static
Code:
function CheckCommentForm()
{
new Ajax.Updater('output', base_url+'guestbook/gb_validatePost', {
encoding: 'UTF-8',
method:'post',
postBody:'author='+$F('author') + '&email;='+$F('email') + '&page;='+$F('page') + '&text;='+$F('text') + '&postid;='+$F('postid') + '&ip;='+$F('ip'),
//onComplete:'showResponse',
onComplete: function(t) {
alert('complete');
},
onFailure: function(t) {
alert('Error ' + t.status + ' -- ' + t.statusText);
}
});
alert('checkcommentform');
//return false; // To stop further processing.
}
window.onload = function () {
$('AddGBCommentForm').onsubmit = function () {
CheckCommentForm();
return false; // To stop further processing.
}
}
When i dont use the postbody in the static-page it all runs trough perfect. =/
Need help with this problem as fast as possible !
best regards !