chechbox validations

Reply

Join Date: Oct 2009
Posts: 185
Reputation: venkat0904 is an unknown quantity at this point 
Solved Threads: 19
venkat0904's Avatar
venkat0904 venkat0904 is offline Offline
Junior Poster
 
0
  #11
Nov 6th, 2009
okkk now i see what u r trying to do...
u can do this easily through javascript... see this

  1. function CountChecks() { // call this function on onClick event of checkboxes
  2. var maxchecked = 2;
  3. var count = 0;
  4. if(document.Form.check1.checked == true) { count++; }
  5. if(document.Form.check2.checked == true) { count++; }
  6. if(document.Form.check3.checked == true) { count++; }
  7. if(document.Form.check4.checked == true) { count++; }
  8. if(document.Form.check5.checked == true) { count++; }
  9. if(document.Form.check6.checked == true) { count++; }
  10. if(document.Form.check7.checked == true) { count++; }
  11. if(count > maxchecked) {
  12. alert('only ' + maxchecked + ' may be checked.');
  13. }
  14. }

Hope this helps...

Originally Posted by muralikalpana View Post
k.......i know that point. but have you see some examples like this...................."you have to select only 2choices from multiple checkboxes". there is 7 boxes is there but select 2choices only. k. got the point?
Last edited by venkat0904; Nov 6th, 2009 at 7:06 am.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 128
Reputation: muralikalpana is an unknown quantity at this point 
Solved Threads: 7
muralikalpana's Avatar
muralikalpana muralikalpana is offline Offline
Junior Poster
 
0
  #12
30 Days Ago
Originally Posted by pritaeas View Post
Found this link, and made it into this:
http://expressionengine.com/forums/viewthread/128806/

  1. <html>
  2. <head>
  3. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
  4. <script type="text/javascript">
  5. $(document).ready(function() {
  6. var total = 0;
  7.  
  8. function calcTotal()
  9. {
  10. $("input:checked").each(function()
  11. {
  12. var value = $(this).attr("value");
  13. total += parseFloat(value);
  14. });
  15. }
  16.  
  17. calcTotal();
  18.  
  19. $("input:checkbox, input:radio").click(function()
  20. {
  21. total = 0;
  22. calcTotal();
  23. $("input#total").val(total);
  24. });
  25. });
  26. </script>
  27. </head>
  28. <body>
  29. <form name="form" action="" method="post" >
  30. <table align="center">
  31. <tr>
  32. <td>Make my add featured $19.95 (your ad seen before free listings)</td>
  33. <td>&nbsp;</td>
  34. <td><input type="checkbox" value="19.95" /></td>
  35. </tr>
  36. <tr>
  37. <td>Make my ad bold $4.95</td>
  38. <td>&nbsp;</td>
  39. <td><input type="checkbox" value="4.95" /></td>
  40. </tr>
  41. <tr>
  42. <td>Make my ad highlighted $4.95</td>
  43. <td>&nbsp;</td>
  44. <td><input type="checkbox" value="4.95" /></td>
  45. </tr>
  46. <tr>
  47. <td>Add Email $9.95</td>
  48. <td><input type="text" name="email" /></td>
  49. <td><input type="checkbox" value="9.95" /></td>
  50. </tr>
  51. <tr>
  52. <td>Add link to my website $9.95</td>
  53. <td><input type="text" name="link" /></td>
  54. <td><input type="checkbox" value="9.95" /></td>
  55. </tr>
  56. <tr>
  57. <td>Add 10 key words $9.95 <input type="checkbox" value="9.95" /></td>
  58. <td>or</td>
  59. <td>Add 20 keywords $19.95 <input type="checkbox" value="19.95" /></td>
  60. </tr>
  61. <tr>
  62. <td><textarea name="text1" rows="6" cols="50"></textarea></td>
  63. <td>&nbsp;</td>
  64. <td>&nbsp;</td>
  65. </tr>
  66. <tr>
  67. <td>Add larger description (up to 4,000 charters) $29.95</td>
  68. <td>&nbsp;</td>
  69. <td><input type="checkbox" value="29.95" /></td>
  70. </tr>
  71. <tr>
  72. <td><textarea name="text1" rows="6" cols="50"></textarea></td>
  73. <td>&nbsp;</td>
  74. <td>&nbsp;</td>
  75. </tr>
  76. <tr>
  77. <td>Add 10 key words $9.95 <input type="checkbox" value="9.95" /></td>
  78. <td>or</td>
  79. <td>Add 20 keywords $19.95 <input type="checkbox" value="19.95" /></td>
  80. </tr>
  81. <tr>
  82. <td><textarea name="text1" rows="6" cols="50"></textarea></td>
  83. <td>&nbsp;</td>
  84. <td>&nbsp;</td>
  85. </tr>
  86. <tr>
  87. <td>&nbsp;</td>
  88. <td>&nbsp;</td>
  89. <td align="right">total <input id="total" type="text" /></td>
  90. </tr>
  91. </table>
  92. </form>
  93. </body>
  94. </html>
in the above example selected values redirecting to another page with user ids. i am putting each value in session.like this
  1. $_SESSION['fcheckbox']=$_REQUEST['fcheckbox']
and next i have "table" in database. if particular session value
exists that column only update.
i wrote like this
  1. if($_SESSION['fcheckbox']!='')
  2. {
  3. $add_update=mysql_query("UPDATE pro_listings SET featured='Y' where id=$_SESSION['add_id'] ");
  4. }
the problem is there is 10 session values is there. among them 5 session values are null. but i want to update existing session values only ,not null values.
and also there is another solution to write update query to each session value like above. any alternative to write single line.
Last edited by muralikalpana; 30 Days Ago at 2:23 am.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 45
Reputation: rohitrohitrohit is an unknown quantity at this point 
Solved Threads: 3
rohitrohitrohit's Avatar
rohitrohitrohit rohitrohitrohit is offline Offline
Light Poster

u can do this way

 
0
  #13
30 Days Ago
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>Total Problem Solved</title>
  6. <script language="javascript" type="text/javascript">
  7. function ttl()
  8. {
  9. var t=0;
  10. if(document.form.chk1.checked == true) {
  11. t=t+parseFloat(document.form.chk1.value);
  12. } if(document.form.chk2.checked == true) {
  13. t=t+parseFloat(document.form.chk2.value);
  14. }if(document.form.chk3.checked == true) {
  15. t=t+parseFloat(document.form.chk3.value);
  16. }if(document.form.chk4.checked == true) {
  17. t=t+parseFloat(document.form.chk4.value);
  18. }if(document.form.chk5.checked == true) {
  19. t=t+parseFloat(document.form.chk5.value);
  20. }if(document.form.chk6.checked == true) {
  21. t=t+parseFloat(document.form.chk6.value);
  22. }if(document.form.chk7.checked == true) {
  23. t=t+parseFloat(document.form.chk7.value);
  24. }if(document.form.chk8.checked == true) {
  25. t=t+parseFloat(document.form.chk8.value);
  26. }
  27. document.form.total.value=t;}
  28. function ch6(){if(document.form.chk6.checked == true) {
  29. document.form.chk7.checked = false ;
  30. document.form.chk8.checked = false;
  31. }ttl();
  32. }
  33. function ch7(){if(document.form.chk7.checked == true) {
  34. document.form.chk6.checked = false ;
  35. document.form.chk8.checked = false;
  36. }ttl();
  37. }
  38. function ch8(){if(document.form.chk8.checked == true) {
  39. document.form.chk6.checked = false ;
  40. document.form.chk7.checked = false;
  41. }ttl();
  42. }
  43. </script>
  44. </head>
  45. <body>
  46. <form name="form" action="" method="post" >
  47. <table align="center">
  48. <tr>
  49. <td>&nbsp;</td>
  50. </tr>
  51. <tr>
  52. <td>&nbsp;</td>
  53. </tr>
  54. <tr>
  55. <td>&nbsp;</td>
  56. </tr>
  57. <tr>
  58. <td>
  59. Make my add featured $19.95 (your ad seen before free listings)</td>
  60. <td>&nbsp;</td>
  61. <td><input type="checkbox" name="chk1" value="19.95" onclick="ttl()"/></td></tr>
  62. <tr>
  63. <td>&nbsp;</td>
  64. <td>&nbsp;</td>
  65. </tr>
  66. <tr>
  67. <td>
  68. Make my ad bold $4.95</td>
  69. <td>&nbsp;</td>
  70. <td><input type="checkbox" name="chk2" value="4.95" onclick="ttl()"/></td></tr>
  71. <tr>
  72. <td>&nbsp;</td>
  73. <td>&nbsp;</td>
  74. </tr>
  75. <tr>
  76. <td>
  77. Make my ad highlighted $4.95</td>
  78. <td>&nbsp;</td>
  79. <td><input type="checkbox" name="chk3" value="4.95" onclick="ttl()"/></td></tr>
  80. <tr>
  81. <td>&nbsp;</td>
  82. <td>&nbsp;</td>
  83. </tr>
  84. <tr>
  85. <td>
  86. Add Email $9.95</td>
  87. <td><input type="text" name="email" /></td>
  88. <td><input type="checkbox" name="chk4" value="9.95" onclick="ttl()"/></td></tr>
  89. <tr>
  90. <td>&nbsp;</td>
  91. <td>&nbsp;</td>
  92. </tr>
  93. <tr>
  94. <td>
  95. Add link to my website $9.95</td>
  96. <td><input type="text" name="link" /></td>
  97. <td><input type="checkbox" name="chk5" value="9.95" onclick="ttl()"/></td>
  98. </tr>
  99. <tr>
  100. <td>&nbsp;</td>
  101. <td>&nbsp;</td>
  102. </tr>
  103. <tr>
  104. <td>Add 10 key words $9.95&nbsp;&nbsp;&nbsp;<input type="checkbox" name="chk6" value="9.95" onclick="ch6()"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  105. or</td>
  106. <td>Add 20 keywords $19.95&nbsp;&nbsp;&nbsp;<input type="checkbox" name="chk7" value="19.95" onclick="ch7()"/></td>
  107. </tr>
  108.  
  109. <tr>
  110. <td>&nbsp;</td>
  111. <td>&nbsp;</td>
  112. </tr>
  113. <tr>
  114. <td>
  115. Add larger description (up to 4,000 charters) $29.95</td>
  116. <td>&nbsp;</td>
  117. <td><input type="checkbox" name="chk8" value="29.95" onclick="ch8()"/></td></tr>
  118. <tr>
  119. <td>&nbsp;</td>
  120. <td>&nbsp;</td>
  121. </tr>
  122. <tr>
  123. <td><textarea name="text1" rows="6" cols="50"></textarea></td>
  124. <td>&nbsp;</td>
  125. </tr>
  126. <tr>
  127. <td>&nbsp;</td>
  128. <td>&nbsp;</td>
  129. </tr>
  130. <tr>
  131. <td align="right">total &nbsp;&nbsp;&nbsp;<input name="total" type="text" disabled="disabled" /></td>
  132. </tr>
  133. </table>
  134. </form>
  135. </body>
  136. </html>
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 128
Reputation: muralikalpana is an unknown quantity at this point 
Solved Threads: 7
muralikalpana's Avatar
muralikalpana muralikalpana is offline Offline
Junior Poster
 
0
  #14
30 Days Ago
Originally Posted by rohitrohitrohit View Post
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>Total Problem Solved</title>
  6. <script language="javascript" type="text/javascript">
  7. function ttl()
  8. {
  9. var t=0;
  10. if(document.form.chk1.checked == true) {
  11. t=t+parseFloat(document.form.chk1.value);
  12. } if(document.form.chk2.checked == true) {
  13. t=t+parseFloat(document.form.chk2.value);
  14. }if(document.form.chk3.checked == true) {
  15. t=t+parseFloat(document.form.chk3.value);
  16. }if(document.form.chk4.checked == true) {
  17. t=t+parseFloat(document.form.chk4.value);
  18. }if(document.form.chk5.checked == true) {
  19. t=t+parseFloat(document.form.chk5.value);
  20. }if(document.form.chk6.checked == true) {
  21. t=t+parseFloat(document.form.chk6.value);
  22. }if(document.form.chk7.checked == true) {
  23. t=t+parseFloat(document.form.chk7.value);
  24. }if(document.form.chk8.checked == true) {
  25. t=t+parseFloat(document.form.chk8.value);
  26. }
  27. document.form.total.value=t;}
  28. function ch6(){if(document.form.chk6.checked == true) {
  29. document.form.chk7.checked = false ;
  30. document.form.chk8.checked = false;
  31. }ttl();
  32. }
  33. function ch7(){if(document.form.chk7.checked == true) {
  34. document.form.chk6.checked = false ;
  35. document.form.chk8.checked = false;
  36. }ttl();
  37. }
  38. function ch8(){if(document.form.chk8.checked == true) {
  39. document.form.chk6.checked = false ;
  40. document.form.chk7.checked = false;
  41. }ttl();
  42. }
  43. </script>
  44. </head>
  45. <body>
  46. <form name="form" action="" method="post" >
  47. <table align="center">
  48. <tr>
  49. <td>&nbsp;</td>
  50. </tr>
  51. <tr>
  52. <td>&nbsp;</td>
  53. </tr>
  54. <tr>
  55. <td>&nbsp;</td>
  56. </tr>
  57. <tr>
  58. <td>
  59. Make my add featured $19.95 (your ad seen before free listings)</td>
  60. <td>&nbsp;</td>
  61. <td><input type="checkbox" name="chk1" value="19.95" onclick="ttl()"/></td></tr>
  62. <tr>
  63. <td>&nbsp;</td>
  64. <td>&nbsp;</td>
  65. </tr>
  66. <tr>
  67. <td>
  68. Make my ad bold $4.95</td>
  69. <td>&nbsp;</td>
  70. <td><input type="checkbox" name="chk2" value="4.95" onclick="ttl()"/></td></tr>
  71. <tr>
  72. <td>&nbsp;</td>
  73. <td>&nbsp;</td>
  74. </tr>
  75. <tr>
  76. <td>
  77. Make my ad highlighted $4.95</td>
  78. <td>&nbsp;</td>
  79. <td><input type="checkbox" name="chk3" value="4.95" onclick="ttl()"/></td></tr>
  80. <tr>
  81. <td>&nbsp;</td>
  82. <td>&nbsp;</td>
  83. </tr>
  84. <tr>
  85. <td>
  86. Add Email $9.95</td>
  87. <td><input type="text" name="email" /></td>
  88. <td><input type="checkbox" name="chk4" value="9.95" onclick="ttl()"/></td></tr>
  89. <tr>
  90. <td>&nbsp;</td>
  91. <td>&nbsp;</td>
  92. </tr>
  93. <tr>
  94. <td>
  95. Add link to my website $9.95</td>
  96. <td><input type="text" name="link" /></td>
  97. <td><input type="checkbox" name="chk5" value="9.95" onclick="ttl()"/></td>
  98. </tr>
  99. <tr>
  100. <td>&nbsp;</td>
  101. <td>&nbsp;</td>
  102. </tr>
  103. <tr>
  104. <td>Add 10 key words $9.95&nbsp;&nbsp;&nbsp;<input type="checkbox" name="chk6" value="9.95" onclick="ch6()"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  105. or</td>
  106. <td>Add 20 keywords $19.95&nbsp;&nbsp;&nbsp;<input type="checkbox" name="chk7" value="19.95" onclick="ch7()"/></td>
  107. </tr>
  108.  
  109. <tr>
  110. <td>&nbsp;</td>
  111. <td>&nbsp;</td>
  112. </tr>
  113. <tr>
  114. <td>
  115. Add larger description (up to 4,000 charters) $29.95</td>
  116. <td>&nbsp;</td>
  117. <td><input type="checkbox" name="chk8" value="29.95" onclick="ch8()"/></td></tr>
  118. <tr>
  119. <td>&nbsp;</td>
  120. <td>&nbsp;</td>
  121. </tr>
  122. <tr>
  123. <td><textarea name="text1" rows="6" cols="50"></textarea></td>
  124. <td>&nbsp;</td>
  125. </tr>
  126. <tr>
  127. <td>&nbsp;</td>
  128. <td>&nbsp;</td>
  129. </tr>
  130. <tr>
  131. <td align="right">total &nbsp;&nbsp;&nbsp;<input name="total" type="text" disabled="disabled" /></td>
  132. </tr>
  133. </table>
  134. </form>
  135. </body>
  136. </html>
ok. fine .
after this i am redirecting to another page from this page. in there i am creating sessions to each value.
  1. $_SESSION[chk1]=$_REQUEST[chk1];
  2. $_SESSION[chk2]=$_REQUEST[chk2];
  3. $_SESSION[chk3]=$_REQUEST[chk3]
like that assigning sessions to all values.
after that i will update table which is in database.
for suppose i was selected only 2 checkboxes in first page.
that fields only update without passing null values to other column values
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 45
Reputation: rohitrohitrohit is an unknown quantity at this point 
Solved Threads: 3
rohitrohitrohit's Avatar
rohitrohitrohit rohitrohitrohit is offline Offline
Light Poster

Is this what you wanted

 
0
  #15
29 Days Ago
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>Total Problem Solved</title>
  6. <script language="javascript" type="text/javascript">
  7. function ttl()
  8. {
  9. var tv="", t=0;
  10. if(document.form.chk1.checked == true) {
  11. t=t+parseFloat(document.form.chk1.value);
  12. tv=tv+'chk1=\''+document.form.chk1.value+'\',';
  13. } if(document.form.chk2.checked == true) {
  14. t=t+parseFloat(document.form.chk2.value);
  15. tv=tv+'chk2=\''+document.form.chk2.value+'\',';
  16. }if(document.form.chk3.checked == true) {
  17. t=t+parseFloat(document.form.chk3.value);
  18. tv=tv+'chk3=\''+document.form.chk3.value+'\',';
  19. }if(document.form.chk4.checked == true) {
  20. t=t+parseFloat(document.form.chk4.value);
  21. tv=tv+'chk4=\''+document.form.chk4.value+'\',';
  22. }if(document.form.chk5.checked == true) {
  23. t=t+parseFloat(document.form.chk5.value);
  24. tv=tv+'chk5=\''+document.form.chk5.value+'\',';
  25. }if(document.form.chk6.checked == true) {
  26. t=t+parseFloat(document.form.chk6.value);
  27. tv=tv+'chk6=\''+document.form.chk6.value+'\',';
  28. }if(document.form.chk7.checked == true) {
  29. t=t+parseFloat(document.form.chk7.value);
  30. tv=tv+'chk7=\''+document.form.chk7.value+'\',';
  31. }if(document.form.chk8.checked == true) {
  32. t=t+parseFloat(document.form.chk8.value);
  33. tv=tv+'chk8=\''+document.form.chk8.value+'\',';
  34. }
  35. document.form.total.value=t;
  36. document.form.query.value="update p set "+tv+"total=\'"+t+'\'';
  37. }
  38. function ch6(){if(document.form.chk6.checked == true) {
  39. document.form.chk7.checked = false ;
  40. document.form.chk8.checked = false;
  41. }ttl();
  42. }
  43. function ch7(){if(document.form.chk7.checked == true) {
  44. document.form.chk6.checked = false ;
  45. document.form.chk8.checked = false;
  46. }ttl();
  47. }
  48. function ch8(){if(document.form.chk8.checked == true) {
  49. document.form.chk6.checked = false ;
  50. document.form.chk7.checked = false;
  51. }ttl();
  52. }
  53. </script>
  54. </head>
  55. <body>
  56. <form name="form" action='redir.php?w=' method="post" >
  57. <table align="center">
  58. <tr>
  59. <td>&nbsp;</td>
  60. </tr>
  61. <tr>
  62. <td><input type="text" name="query" id="query"/></td>
  63. </tr>
  64. <tr>
  65. <td>&nbsp;</td>
  66. </tr>
  67. <tr>
  68. <td>
  69. Make my add featured $19.95 (your ad seen before free listings)</td>
  70. <td>&nbsp;</td>
  71. <td><input type="checkbox" name="chk1" value="19.95" onclick="ttl()"/></td></tr>
  72. <tr>
  73. <td>&nbsp;</td>
  74. <td>&nbsp;</td>
  75. </tr>
  76. <tr>
  77. <td>
  78. Make my ad bold $4.95</td>
  79. <td>&nbsp;</td>
  80. <td><input type="checkbox" name="chk2" value="4.95" onclick="ttl()"/></td></tr>
  81. <tr>
  82. <td>&nbsp;</td>
  83. <td>&nbsp;</td>
  84. </tr>
  85. <tr>
  86. <td>
  87. Make my ad highlighted $4.95</td>
  88. <td>&nbsp;</td>
  89. <td><input type="checkbox" name="chk3" value="4.95" onclick="ttl()"/></td></tr>
  90. <tr>
  91. <td>&nbsp;</td>
  92. <td>&nbsp;</td>
  93. </tr>
  94. <tr>
  95. <td>
  96. Add Email $9.95</td>
  97. <td><input type="text" name="email" /></td>
  98. <td><input type="checkbox" name="chk4" value="9.95" onclick="ttl()"/></td></tr>
  99. <tr>
  100. <td>&nbsp;</td>
  101. <td>&nbsp;</td>
  102. </tr>
  103. <tr>
  104. <td>
  105. Add link to my website $9.95</td>
  106. <td><input type="text" name="link" /></td>
  107. <td><input type="checkbox" name="chk5" value="9.95" onclick="ttl()"/></td>
  108. </tr>
  109. <tr>
  110. <td>&nbsp;</td>
  111. <td>&nbsp;</td>
  112. </tr>
  113. <tr>
  114. <td>Add 10 key words $9.95&nbsp;&nbsp;&nbsp;<input type="checkbox" name="chk6" value="9.95" onclick="ch6()"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  115. or</td>
  116. <td>Add 20 keywords $19.95&nbsp;&nbsp;&nbsp;<input type="checkbox" name="chk7" value="19.95" onclick="ch7()"/></td>
  117. </tr>
  118.  
  119. <tr>
  120. <td>&nbsp;</td>
  121. <td>&nbsp;</td>
  122. </tr>
  123. <tr>
  124. <td>
  125. Add larger description (up to 4,000 charters) $29.95</td>
  126. <td>&nbsp;</td>
  127. <td><input type="checkbox" name="chk8" value="29.95" onclick="ch8()"/></td></tr>
  128. <tr>
  129. <td>&nbsp;</td>
  130. <td>&nbsp;</td>
  131. </tr>
  132. <tr>
  133. <td><textarea name="text1" rows="6" cols="50"></textarea></td>
  134. <td>&nbsp;</td>
  135. </tr>
  136. <tr>
  137. <td>&nbsp;</td>
  138. <td>&nbsp;</td>
  139. </tr>
  140. <tr>
  141. <td align="right">total &nbsp;&nbsp;&nbsp;<input name="total" type="text" disabled="disabled" /><input type="submit" value="Done" /></td>
  142. </tr>
  143. </table>
  144. </form>
  145. </body>
  146. </html>
redir.php file
  1. <?php
  2. $q=stripslashes($_POST['query']);
  3. echo "".$q;
  4. include("config.php");
  5. global $conn;
  6. $result=mysql_query($q,$conn) or die("error".mysql_error());
  7. $nm=mysql_affected_rows();
  8. if($nm!=0)
  9. {echo "Inserted";}else{echo "Error";}
  10. ?>
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 128
Reputation: muralikalpana is an unknown quantity at this point 
Solved Threads: 7
muralikalpana's Avatar
muralikalpana muralikalpana is offline Offline
Junior Poster
 
0
  #16
29 Days Ago
Originally Posted by rohitrohitrohit View Post
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>Total Problem Solved</title>
  6. <script language="javascript" type="text/javascript">
  7. function ttl()
  8. {
  9. var tv="", t=0;
  10. if(document.form.chk1.checked == true) {
  11. t=t+parseFloat(document.form.chk1.value);
  12. tv=tv+'chk1=\''+document.form.chk1.value+'\',';
  13. } if(document.form.chk2.checked == true) {
  14. t=t+parseFloat(document.form.chk2.value);
  15. tv=tv+'chk2=\''+document.form.chk2.value+'\',';
  16. }if(document.form.chk3.checked == true) {
  17. t=t+parseFloat(document.form.chk3.value);
  18. tv=tv+'chk3=\''+document.form.chk3.value+'\',';
  19. }if(document.form.chk4.checked == true) {
  20. t=t+parseFloat(document.form.chk4.value);
  21. tv=tv+'chk4=\''+document.form.chk4.value+'\',';
  22. }if(document.form.chk5.checked == true) {
  23. t=t+parseFloat(document.form.chk5.value);
  24. tv=tv+'chk5=\''+document.form.chk5.value+'\',';
  25. }if(document.form.chk6.checked == true) {
  26. t=t+parseFloat(document.form.chk6.value);
  27. tv=tv+'chk6=\''+document.form.chk6.value+'\',';
  28. }if(document.form.chk7.checked == true) {
  29. t=t+parseFloat(document.form.chk7.value);
  30. tv=tv+'chk7=\''+document.form.chk7.value+'\',';
  31. }if(document.form.chk8.checked == true) {
  32. t=t+parseFloat(document.form.chk8.value);
  33. tv=tv+'chk8=\''+document.form.chk8.value+'\',';
  34. }
  35. document.form.total.value=t;
  36. document.form.query.value="update p set "+tv+"total=\'"+t+'\'';
  37. }
  38. function ch6(){if(document.form.chk6.checked == true) {
  39. document.form.chk7.checked = false ;
  40. document.form.chk8.checked = false;
  41. }ttl();
  42. }
  43. function ch7(){if(document.form.chk7.checked == true) {
  44. document.form.chk6.checked = false ;
  45. document.form.chk8.checked = false;
  46. }ttl();
  47. }
  48. function ch8(){if(document.form.chk8.checked == true) {
  49. document.form.chk6.checked = false ;
  50. document.form.chk7.checked = false;
  51. }ttl();
  52. }
  53. </script>
  54. </head>
  55. <body>
  56. <form name="form" action='redir.php?w=' method="post" >
  57. <table align="center">
  58. <tr>
  59. <td>&nbsp;</td>
  60. </tr>
  61. <tr>
  62. <td><input type="text" name="query" id="query"/></td>
  63. </tr>
  64. <tr>
  65. <td>&nbsp;</td>
  66. </tr>
  67. <tr>
  68. <td>
  69. Make my add featured $19.95 (your ad seen before free listings)</td>
  70. <td>&nbsp;</td>
  71. <td><input type="checkbox" name="chk1" value="19.95" onclick="ttl()"/></td></tr>
  72. <tr>
  73. <td>&nbsp;</td>
  74. <td>&nbsp;</td>
  75. </tr>
  76. <tr>
  77. <td>
  78. Make my ad bold $4.95</td>
  79. <td>&nbsp;</td>
  80. <td><input type="checkbox" name="chk2" value="4.95" onclick="ttl()"/></td></tr>
  81. <tr>
  82. <td>&nbsp;</td>
  83. <td>&nbsp;</td>
  84. </tr>
  85. <tr>
  86. <td>
  87. Make my ad highlighted $4.95</td>
  88. <td>&nbsp;</td>
  89. <td><input type="checkbox" name="chk3" value="4.95" onclick="ttl()"/></td></tr>
  90. <tr>
  91. <td>&nbsp;</td>
  92. <td>&nbsp;</td>
  93. </tr>
  94. <tr>
  95. <td>
  96. Add Email $9.95</td>
  97. <td><input type="text" name="email" /></td>
  98. <td><input type="checkbox" name="chk4" value="9.95" onclick="ttl()"/></td></tr>
  99. <tr>
  100. <td>&nbsp;</td>
  101. <td>&nbsp;</td>
  102. </tr>
  103. <tr>
  104. <td>
  105. Add link to my website $9.95</td>
  106. <td><input type="text" name="link" /></td>
  107. <td><input type="checkbox" name="chk5" value="9.95" onclick="ttl()"/></td>
  108. </tr>
  109. <tr>
  110. <td>&nbsp;</td>
  111. <td>&nbsp;</td>
  112. </tr>
  113. <tr>
  114. <td>Add 10 key words $9.95&nbsp;&nbsp;&nbsp;<input type="checkbox" name="chk6" value="9.95" onclick="ch6()"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  115. or</td>
  116. <td>Add 20 keywords $19.95&nbsp;&nbsp;&nbsp;<input type="checkbox" name="chk7" value="19.95" onclick="ch7()"/></td>
  117. </tr>
  118.  
  119. <tr>
  120. <td>&nbsp;</td>
  121. <td>&nbsp;</td>
  122. </tr>
  123. <tr>
  124. <td>
  125. Add larger description (up to 4,000 charters) $29.95</td>
  126. <td>&nbsp;</td>
  127. <td><input type="checkbox" name="chk8" value="29.95" onclick="ch8()"/></td></tr>
  128. <tr>
  129. <td>&nbsp;</td>
  130. <td>&nbsp;</td>
  131. </tr>
  132. <tr>
  133. <td><textarea name="text1" rows="6" cols="50"></textarea></td>
  134. <td>&nbsp;</td>
  135. </tr>
  136. <tr>
  137. <td>&nbsp;</td>
  138. <td>&nbsp;</td>
  139. </tr>
  140. <tr>
  141. <td align="right">total &nbsp;&nbsp;&nbsp;<input name="total" type="text" disabled="disabled" /><input type="submit" value="Done" /></td>
  142. </tr>
  143. </table>
  144. </form>
  145. </body>
  146. </html>
redir.php file
  1. <?php
  2. $q=stripslashes($_POST['query']);
  3. echo "".$q;
  4. include("config.php");
  5. global $conn;
  6. $result=mysql_query($q,$conn) or die("error".mysql_error());
  7. $nm=mysql_affected_rows();
  8. if($nm!=0)
  9. {echo "Inserted";}else{echo "Error";}
  10. ?>
wonderful!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 128
Reputation: muralikalpana is an unknown quantity at this point 
Solved Threads: 7
muralikalpana's Avatar
muralikalpana muralikalpana is offline Offline
Junior Poster
 
0
  #17
29 Days Ago
  1. document.form.query.value="update p set "+tv+"total=\'"+t+'\'';
but there is no need total.
so i wrote like this .....this is not working.
  1. document.form.query.value="update user_registration set "+tv+'\''+"where";
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 45
Reputation: rohitrohitrohit is an unknown quantity at this point 
Solved Threads: 3
rohitrohitrohit's Avatar
rohitrohitrohit rohitrohitrohit is offline Offline
Light Poster

This is it

 
0
  #18
28 Days Ago
  1. var i=1;
  2. var strLen = tv.length;
  3. tv = tv.slice(0,strLen-1);
  4. document.form.query.value="update p set "+tv+" where id=\'"+i+'\'';
where i is your id
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC