Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Two ajax forms on a page !!

innerHTML ajax

  • Please log in to reply
1 reply to this topic

#1 evilhackerz

evilhackerz

    CC Lurker

  • Just Joined
  • Pip
  • 4 posts

Posted 22 June 2010 - 03:08 PM

i m using two ajax two ajax on 1 page n 1 word counter jquery .problem is that , at one time only one function working...
like if i just use reply box and word count... it will work,bt like button will now work.
what i identify that there 3 three scripts in <head> ,,which script will i place on top will not work and other two feature will work.
try it, and plz solve the problem. dont change the variable names... if i write anything wrong then tell me where i have to do changes...



scripts under <head> tag are :

<script type="text/javascript" src="js/prototype.js"></script>
<script>

function sendRequest() {
new Ajax.Request("likepost.php",
{
method: 'post',
postBody: 'name='+ $F('name'),
onComplete: showResponse
});
}

function showResponse(req){
$('show').innerHTML= req.responseText;
}
</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("form#reply").submit(function() {
// we want to store the values from the form input box, then send via ajax below
var reply1 = $('#reply1').attr('value');
var pid = $('#pid').attr('value');
$.ajax({
type: "POST",
url: "replypost.php",
data: "reply1="+ reply1 +"& pid="+ pid,
success: function(){
$('form#reply').hide(function(){$('div.success').fadeIn();});

}
});
return false;
});
});
</script>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$("#reply1").keyup(function()
{
var box=$(this).val();
var main = box.length *100;
var value= (main / 1000);
var count= 1000 - box.length;

if(box.length <= 1000)
{
$('#count').html(count);
$('#bar').animate(
{
"width": value+'%',
}, 1);
}
else
{
alert(' Full ');
}
return false;
});

});
</script>


_________________________________________________

and body part of these 3 scripts are :



<form id="test" onSubmit="return false;">
<input type="hidden" name="name" id="name" value="<?php echo $id ?>" >
<input type="submit" value="Like This Post ?" onClick="sendRequest()">
</form>






and




<div>
<div id="count">1000</div>
<div id="barbox"><div id="bar"></div></div>
</div>
<form id="reply" method="post">
<textarea name="reply1" id="reply1" cols="100" rows="5"></textarea><br/>
<input type="hidden" name="pid" id="pid" value="<?php echo $id ?>"><br/>
<input id="v" name="submit1" class="button positive" type="submit" value="submit">
</form>
</div>
<div align="center" class="success" style="display: none;">Your Comment Has Been Moderated – Stay Tuned for Approval.</div>
<div>

</div>

________________________
  • 0

#2 ferovac

ferovac

    CC Resident

  • Just Joined
  • PipPipPipPip
  • 83 posts

Posted 28 June 2010 - 09:09 PM

code tags edit you post and put code or even better html tags around your code
  • 0





Also tagged with one or more of these keywords: innerHTML, ajax

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download