0
I need to know how to submit the form id, which varies according to the post ID, which would be something like myForm'. $id. ' to be able to treat each form itself. The form is sent through the script:
function rpbox(value, valor) {
$(document).ready(function() {
$("#"+value).keydown(function(evt) {
var message = $("#"+value).val();
if (evt.keyCode == 13 && !evt.shiftKey) {
if (message != ''){
if (document.getElementById("reply_box"+valor).style.display == "none") {
document.getElementById("reply_box"+valor).style.display = "table";
document.getElementById("l"+valor).style.display = "none";
}
$("#myForm"+valor).submit();
}
$("textarea").val('');
evt.preventDefault();
return false;
}
});
});
}
This script would be to handle the form I need to handle the Iddoform.
$(document).ready(function() {
$("#"+IDdoform).ajaxForm({
target: ".comment_all",
type: "POST",
success: function(){
$(".comment_all").append;
}
});
});
Another issue is that I have a "button" that shows the amount of existing comments, but when added by ajax, the button gets the previous amount. I have no idea if there’s any way to update him.
<input class="lsubmit4" type="button" name="'.$post['id_p'].'" value="Comment ('.$rows.')" onclick="openReply(this.name)"/>
$(document).ready(function() {
function rpbox(value, valor) {
$("#"+value).keydown(function(evt) {
var message = $("#"+value).val();
if (evt.keyCode == 13 && !evt.shiftKey) {
if (message != ''){
if (document.getElementById("reply_box"+valor).style.display == "none") {
document.getElementById("reply_box"+valor).style.display = "table";
document.getElementById("l"+valor).style.display = "none";
}
$("#myForm"+valor).trigger("submit", valor);
}
$("textarea").val('');
}
});
}
$(".imagem_news").click(function(){
var id = this.id;
var valor = this.id.match(/\d+/);
rpbox(id, valor);
});
$("form").submit(function(e, i){
var myForm = "myForm"+i;
e.preventDefault();
$("#"+myForm).ajaxForm({
type: 'POST',
url: 'processing.php',
target: '.comment_all',
success: function(){
$(".comment_all").append;
}
});
});
});
Have you tried sending by
data: { idform: IDdoform}
?– Sam
In the case of the button, as it is sent by PHP, I think you should take the updated value after making a query to the bank taking the amount and adding +1, if that’s what I understood.
– Sam
@Sam the date I would have to use inside the ajaxForm, no? I need to receive this Iddoform before calling the ajax. The form id is usually myForm'. $post['id'].'.
– Marciohrm
I get it. In this
$("#"+IDdoform).ajaxForm({
you need the variableIDdoform
is the form ID.– Sam
How is called this function
rpbox
?– Sam
@Sam
<textarea name="editor1" id="text'.$post['id_p'].'" onclick="rpbox(this.id, '.$post['id_p'].')" class="imagem_news" placeholder="Your Comment..." ></textarea>
– Marciohrm
@Sam then, on the button, is there any way to update it without updating the page?
– Marciohrm
You can update the button via Ajax by name:
$("[name="+ID+"]").val("Comment ("+VALOR RETORNADO DO AJAX+")")
– Sam