ajax 2 forms only one works

ok i have two forms on 1 page.

then i have a the ajax getting the var from the form and post it to the php.

the php works it updates the dababase.

BUT it ONLY works for the first form on the page.

the plus IF i i put the second form first then the mines works.

So it only work with the first form and not with both How can i get both working????
and
Why does it do that ???
this is my form

  <form name="plus" method="post" action="">

     <input  style=" display:none"type="text" name="fbid" id="fbid" size="1" value="<?=$fbid?>" class="text-input" />
 
     <input style=" display:none" type="text" name="plus1" id="plus1" size="1" value="1" class="text-input" />
     	<br />
      <input type="submit" name="plus-button" class="button" id="plus_btn" value="+ Good" />
 
  </form>

  <form name="mines" method="post" action="">
   
    
    <input style=" display:none" type="text" name="fbid" id="fbid" size="1" value="<?=$fbid?>" class="text-input" />
   
    <input style=" display:none" type="text" name="mines1" id="mines1" size="1" value="-1" class="text-input" />
    	<br />
      <input type="submit" name="mines-button" class="button" id="mines_btn" value="- Evil" />
   
  </form>


this is my js file 


$(function() {
 
  

  $(".button").click(function() {
		// validate and process form
		// first hide any error messages
  
	  var fbid = $("input#fbid").val();
		
		var mines1 = $("input#mines1").val();
		
		var plus1 = $("input#plus1").val();
		
		
		var dataString = 'fbid='+ fbid + '&mines1=' + mines1 + '&plus1=' + plus1;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "process.php",
      data: dataString,
      success: function() {
       
      }
     });
    return false;
	});
});
runOnLoad(function(){
  $("input#fbid").select().focus();
});


this is my php 

<?php



  $dbuser="fbfbfbf";

	  $dbpassword="fbfbfbfb";

	  $database="fbfbfbfb";

//$fbid = $user_profile['id'];

mysql_connect(localhost,$dbuser,$dbpassword);
mysql_select_db($database) or die( "Unable to select database");

$up = $_POST['plus1'];
$down = $_POST['mines1'];
$fbid = $_POST['fbid'];

if($up == '1') {
       $query1 = "UPDATE Facebook SET click=click+1 WHERE fbid ='$fbid' ";
       $result = mysql_query($query1) or die(mysql_error());
       }

if($down == '-1') {
       $query1 = "UPDATE Facebook SET click=click-1 WHERE fbid ='$fbid' ";
       $result = mysql_query($query1) or die(mysql_error());
       }


   ?>

Open in new window

mikearmasAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

StingRaYCommented:
You can have only one ID in a page. So, change one of your #fbid to some ID else.
0
mikearmasAuthor Commented:
no that didn't work
0
StingRaYCommented:
I wrapped parts of your JS to:

$(function() {
	$(".button").click(function() {
		var dataString = "";
		if ($(this).attr('name')=="plus-button") {
			dataString = $('input.plus').serialize();
		} else {
			dataString = $('input.minus').serialize();
		}
        $.ajax({
			type: "POST",
			url: "process.php",
			data: dataString,
			success: function() {
			}
		});
    });
});

Open in new window


and your FORM to:

  <form name="plus" method="post" action="">

     <input  style=" display:none"type="text" name="fbid" id="fbid" size="1" value="<?=$fbid?>" class="text-input plus minus" />
 
     <input style=" display:none" type="text" name="plus1" id="plus1" size="1" value="1" class="text-input plus" />
     <input style=" display:none" type="text" name="mines1" id="mines1" size="1" value="-1" class="text-input minus" />
      <input type="button" name="plus-button" class="button" id="plus_btn" value="+ Good" />
         <br />
      <input type="button" name="mines-button" class="button" id="mines_btn" value="- Evil" />

  </form>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mikearmasAuthor Commented:
Damn i need to read more about js you got it working thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
AJAX

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.