473,320 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

PHP button's won't function with jQuery

Expand|Select|Wrap|Line Numbers
  1. if(isset($_POST['submit'])) 
  2. mysql_query("UPDATE Blad1 SET
  3. Naam ='$naamveld',
  4. Inkoop='$inkoopveld',
  5. Verkoopprijs='$verkoopveld',
  6. Aantal ='$aantalveld',
  7. Verkocht= '$verkochtveld'
  8. WHERE id = '$id'") 
  9. or die(mysql_error());
  10. echo "Het is aangepast!";
The above text is an example of a submit, and the below text is an example of the input button.

Expand|Select|Wrap|Line Numbers
  1.      echo "<td><div><input type=\"image\" name=\"submit2\" id=\"button\"  src=\"img/onebit_20.png\" value=\"Maak aan!\">";
  2.     echo "</div></td>";
It's using this jQuery
Expand|Select|Wrap|Line Numbers
  1. $(document).ready(function(){
  2. //Setting some variables needed, don't edit these
  3.     var displaySubmit=false, newRowCount=0;
  4. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5. //Define some variables - edit to suit your needs
  6. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7.     var maxRows=5;
  8.     var rowSpeed = 300;
  9.     var $table = $("#tabel");
  10.     var $tableBody = $("tbody",$table);
  11.     var $addRowBtn = $("#addRow");
  12.     var $removeAllBtn= $("#controls #removeAllRows");
  13.     var $hiddenControls = $("#controls .hiddenControls");
  14.     var blankRowID = "blankRow";
  15.     var newRowClass = "newRow";
  16.     var oddRowClass = "rowOdd";
  17.     var evenRowClass = "rowEven"
  18.     var hiddenClass = "hidden"
  19. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  20.  
  21.  
  22. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  23. //click the add button
  24. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  25.     $addRowBtn.click(function(){
  26.         if(newRowCount < maxRows){
  27.             newRowCount++;
  28.             //get the class on the first row...
  29.             if($tableBody.find("tr:first-child").hasClass(evenRowClass)){
  30.                 //the curent first row is even, so we add an odd class
  31.                 newClasses = hiddenClass+" "+newRowClass+" "+oddRowClass;
  32.             }else{
  33.                 //the current first row is odd, so we add an even row
  34.                 newClasses = hiddenClass+" "+newRowClass+" "+evenRowClass;
  35.             }
  36.             //clone the blank row, put the clone at the top, set the correct classes, remove the ID, animate the divs inside
  37.             //normally I'd use .addClass(), but I want the classes I set to replace the current set classes, so I use .attr("class") to overwrite the classes
  38.             newRow = $("#"+blankRowID,$tableBody).clone().appendTo($tableBody).attr("class",newClasses).removeAttr("id").show().find("td div").slideDown(rowSpeed,function(){
  39.                 //run this once animations finish
  40.                 showHideSubmit();
  41.             });
  42.             //Add click event to the remove button on the newly added row
  43.             newRow.find(".removeRow").click(function(){
  44.                 thisRow = $(this).parents("tr");
  45.                 rowRemoved=false;
  46.                 newRowCount--;
  47.                 //animate the row
  48.                 thisRow.find("td div").slideUp(rowSpeed,function(){
  49.                     //this is run once the animation completes
  50.                     if(!rowRemoved){ //this only lets it fire once per row
  51.                         thisRow.remove();
  52.                         showHideSubmit();
  53.                         //make sure alternating rows are correct once a row is removed
  54.                         $tableBody.find("tr:odd").removeClass(evenRowClass).addClass(oddRowClass); //odd rows have an odd class
  55.                         $tableBody.find("tr:even").removeClass(oddRowClass).addClass(evenRowClass);//even rows have an even class
  56.                         if(newRowCount < maxRows){
  57.                             $addRowBtn.removeAttr("disabled");//re-enable the add button
  58.                         }
  59.                     }
  60.                     rowRemoved=true;
  61.                 }); 
  62.                 return false; //kill the browser default action
  63.             });
  64.         }
  65.         //disable button so you know you've reached the max
  66.         if(newRowCount >= maxRows){
  67.             $addRowBtn.attr("disabled","disabled");//set the "disabled" property on the button
  68.         }
  69.         return false; //kill the browser default action
  70.     });
  71. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  72.  
  73.  
  74.  
  75. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  76. //Click the remove all button
  77. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  78.     $removeAllBtn.click(function(){
  79.         //Close all the newly created rows
  80.         $tableBody.find("tr."+newRowClass+"").each(function(){
  81.             newRowCount--;
  82.             showHideSubmit();
  83.             //this happens once for every div that slides - no harm done though
  84.             $(this).find("td div").slideUp(rowSpeed,function(){
  85.                 $(this).parents("."+newRowClass).remove(); //remove this row
  86.                 $addRowBtn.removeAttr("disabled"); //re-enable the add button
  87.             });
  88.         });
  89.         return false;
  90.     });
  91. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  92.  
  93.  
  94.  
  95. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  96. //Function to show or hide the submit/cancel buttons
  97. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  98.     function showHideSubmit(){
  99.         if(newRowCount > 0 && !displaySubmit){
  100.                 //at least one new row is visible, show the hidden controls
  101.                 $hiddenControls.fadeIn(rowSpeed);
  102.                 //partially fade out all rows that are not new and disable links within
  103.                 $tableBody.find("tr:not(#"+blankRowID+", ."+newRowClass+")").fadeTo(rowSpeed,0.25, function(){
  104.                     $(this).find("a").click(function(){return false;});//makes all clicked links go nowhere
  105.                 });
  106.                 displaySubmit= true;
  107.         }else if(newRowCount <= 0){
  108.             //no new rows are shown, hide the controls
  109.             $hiddenControls.fadeOut(rowSpeed);
  110.             //fade old rows back in and re-enable links
  111.             $tableBody.find("tr:not(#"+blankRowID+", ."+newRowClass+")").fadeTo(rowSpeed,1,function(){
  112.                 $(this).find("a").unbind("click");//removes the click event we site above
  113.             });
  114.             newRowCount=0;//Make sure the count is reset to 0...just in case
  115.             displaySubmit= false;
  116.         }
  117.     }
  118. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  119. });
Thanks in advanced!
Mar 4 '11 #1
1 1567
johny10151981
1,059 1GB
It is pretty hard to study this code and reply you,
you better ask specific question
Mar 10 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: TrvlOrm | last post by:
Can any one please help me...I am new to JavaScript and I have been struggling with this code for days now and can't figure it out. I would like to get the Buttons to correspond with the action...
6
by: SimonZ | last post by:
How can you call function from aspx page? For example: button on aspx page: <asp:button Visible="<% =funcVisible()%>" id="btnNew" Runat="server"></asp:button> code behind function:
4
by: hanseymoon | last post by:
Dear newsgroup: I've got this long function, which works good overall to spell check words from a dictionary and I am not in a position to replace it. Can someone please see where or how it...
1
by: papalazarou78 | last post by:
Hi I've been experiementing with actionscripting transitions between sections... this is the first site I have tried this with (last 3 had swf loaded in one after another rather than transitioned...
1
by: mevima | last post by:
I have a small form page, with a submit button and an onclick event. <input type="button" value="Sign Up!" onClick="signUp();"> This worked just fine until I added a new regex function, but...
8
by: rahulnag22 | last post by:
I have created a button widget with a button click binding. The button initially has a state=disabled. I can see the greyed out version of the button in the GUI. But If I click on the button it...
1
by: femtox77 | last post by:
Hi, I try to show or hide a button when I click on checkboxes. I explain better. I'm learnig to use Jquery framework. I have a page with many rows and every row has a checkbox. I wanna show a...
53
by: souporpower | last post by:
Hello All I am trying to activate a link using Jquery. Here is my code; <html> <head> <script type="text/javascript" src="../../resources/js/ jquery-1.2.6.js"</script> <script...
7
Haitashi
by: Haitashi | last post by:
I have a form that calls a function using the onClick event in the submit button. I would like this function to return false if the username is taken. The the original function, which I've tested,...
8
by: thatcollegeguy | last post by:
http://smarterfootball.com/exits/theHTML.html I am not sure what is wrong w/ this code. The main issue is that the table that is in the initial html will empty its td but the table that I load...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.