I've got that code:
- <script>
$(document).ready(function() {
$("#addNews").validate({
errorPlacement: function(error, element) {
error.insertAfter(element.next().next().next());
}
});
});
</script>
It works great, but when I want to send values from fields to php it doesn't work. It just reload a page:
- <script>
$(document).ready(function() {
$("#addNews").validate({
errorPlacement: function(error, element) {
error.insertAfter(element.next().next().next());
},
submitHandler: function() {
var ftitle = $('#medium-input').attr('value');
var fsummary = $('#textarea summary').attr('value');
var fboxytext = $('#textarea bodytext').attr('value');
var fpic = $('#pic').attr('value');
$.ajax({
type: "POST",
url: "write_news_ajax.php",
data: "ftitle="+ ftitle +"& fsummary="+ fsummary"& fboxytext="+ fboxytext"& fpic="+ fpic,
success: function(){
$('form#addNews').hide(function(){$('div.notification success png_bg').fadeIn();});
}
});
}
});
});
</script>
Form looks like that:
- <form id="addNews" method="post" name="submit" action="">
<fieldset> <!-- Set class to "column-left" or "column-right" on fieldsets to divide the form into columns -->
<p>
<label>Temat</label>
<input class="text-input medium-input datepicker required" type="text" id="medium-input" name="title" maxlength="40" /><br /><small>Max. 40 znaków</small><br />
</p>
<p>
<label>Wstęp newsa</label>
<textarea class="text-input textarea required" id="textarea summary" name="summary" cols="79" rows="3" maxlength="172" ></textarea><br /><small>Max. 172 znaki</small> <br />
</p>
<p>
<label>Treść newsa</label>
<textarea class="text-input textarea wysiwyg" id="textarea bodytext" name="bodytext" cols="79" rows="15" maxlength="2000" ></textarea><br /><small>Max. 2000 znaków</small>
</p>
<p>
<div id="picupload_div">
<p><label for="file">Obrazek:</label> <input type="file" name="picupload" id="picupload" /></p>
</div>
<div id="uploadedpics">
<!-- hidden form field posts to here -->
</div>
<p><a href="javascript:jQuery('#uploadify').uploadifyClearQueue()">Zatrzymaj wgrywanie</a></p>
</p>
<p>
<BUTTON type="submit" class="button">Dodaj newsa</BUTTON>
</p>
</fieldset>
<div class="clear"></div><!-- End .clear -->
</form>
Any ideas why it doesn't work?