473,657 Members | 2,266 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP button's won't function with jQuery

4 New Member
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 1578
johny10151981
1,059 Top Contributor
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
2276
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 to either a) generate numbers b) Prompts a user to locate a web page c) go to previous page in history list d) Loads next page in history list e) Promps the user for a URL and loads the web page in a new window f) and Re-Sizes the window. ...
6
1940
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
1446
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 might be chopping up words like: don't. It brings them back as: 't, chopping off the "don" before the apostrophe. I've looked over the whole situation and ran many $string tests....and it appears to be narrowed it down to this. I may be wrong and...
1
3739
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 between). I used some code from kirupa.com which works for loading movies in and out, but I also have some code for my movie buttons. I can get one or the other working, but not together, so I guess I'm clashing code somewhere, I could do with some...
1
1783
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 now it returns an "Error: Object expected" when I click it. I've tried moving the javascript function to the top of the page (inside the head tags) instead of the bottom (above the body tag, both above and below the form tag), all with the same error...
8
11214
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 still invokes the callback/binding function. Any suggestions as to why the callback is being invoked even though the button has a disabled state. It looks like- b=Button(frame, text = "Button", state = 'disabled')
1
3780
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 button only when i check checkboxes. So I can show the button on every click but when i "reclick" to uncheck the checkboxes the button goes away. Any idea? Thank you Fem
53
8370
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 language="javascript" type="text/javascript">
7
11075
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, returns the correct info when the "checkUname" button is clicked. However, it always returns false. I want to return false ONLY if the username is taken. Original: $("#checkUname").click(function(){ var datastring=...
8
3897
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 using php and jquery through a mysql database will not empty the td elements. There is a table underneath the button in the initial html. if you click on a box in the table, it will empty. the same does not happen for the table that is generated by...
0
8319
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8739
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8512
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6175
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2739
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.