submit once button

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Jan 2009
Posts: 1
Reputation: runrunforest is an unknown quantity at this point 
Solved Threads: 0
runrunforest runrunforest is offline Offline
Newbie Poster

submit once button

 
0
  #1
Jan 12th, 2009
Hi,

I want to this, a button that changed to disable when click, while there is something sent to the database.

I worked with ajax, I can do this with a submit button, but when I i put the form tag, not work any more.

Can you give me some available solution for this ?
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 686
Reputation: sillyboy is on a distinguished road 
Solved Threads: 61
sillyboy's Avatar
sillyboy sillyboy is offline Offline
Practically a Master Poster

Re: submit once button

 
0
  #2
Jan 12th, 2009
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <form>
  2. <input type="submit" disabled="disabled">
  3. </form>
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,600
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 462
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: submit once button

 
0
  #3
Jan 13th, 2009
> I worked with ajax, I can do this with a submit button, but when I i
> put the form tag, not work any more.

It worked because Ajax doesn't depend on a FORM element for shipping data to and fro; it uses the XMLHttpRequest object for this purpose.

Also, doesn't work is a pretty useless description, we need more description or a sample snippet which showcases the problem at hand.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 271
Reputation: fatihpiristine has a little shameless behaviour in the past 
Solved Threads: 16
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: submit once button

 
0
  #4
Jan 13th, 2009
dont know how much you know about javascript but this will do the thing that you want.

this one adds butons into body onclick event and changes its label to delete and
delete buton delete any other button randomly (doesnt remove itself)
this was an interview question

object model used to support ie4+

replace document.body.removeChild(btns[tmp]); and add there what you want and it will work.

  1. var q = q ? q : new Object();
  2. /* create document element */
  3. q.CreateElement = function(tagName) {
  4. return document.createElement(tagName);
  5. };
  6. /* set element attribute */
  7. q.SetAttribute = function(element, attName, attValue) {
  8. return element.setAttribute(attName, attValue);
  9. };
  10. /* append element to given parent */
  11. q.AppendChild = function(parent, newChild) {
  12. return parent.appendChild(newChild);
  13. };
  14. /* set element class name */
  15. q.ClassName = function(element, className) {
  16. return element.className = className;
  17. };
  18. /* fetch source element of the event */
  19. q.GetTarget = function(ev) {
  20. var target;
  21. if (!ev) var ev = window.event;
  22. if (ev.target) target = ev.target;
  23. else if (ev.srcElement) target = ev.srcElement;
  24. if (target.nodeType == 3)
  25. target = target.parentNode;
  26. return target;
  27. };
  28. /* button click event */
  29. q.buttonClick = function(event) {
  30. /*
  31. as we cannot pass parameter with the event (possible in IE Browsers),
  32. checking the value of source element.
  33. */
  34. if (q.GetTarget(event).value.indexOf("Add") == 0) {
  35. var newBtn = q.CreateElement("input");
  36. q.SetAttribute(newBtn, "value", "Delete");
  37. q.SetAttribute(newBtn, "type", "button"); /* set type of the input */
  38. /* attach event to new button */
  39. if (newBtn.addEventListener) { /* if FF */
  40. newBtn.addEventListener('click', q.buttonClick, event);
  41. } else { /* if IE */
  42. newBtn.attachEvent('onclick', q.buttonClick);
  43. }
  44. q.ClassName(newBtn, "q");
  45. q.AppendChild(document.body, newBtn);
  46. }
  47. else {
  48. var btns = document.getElementsByTagName("INPUT");
  49. var tmp; /* temporary value */
  50. while (tmp = Math.floor(Math.random() * 10)) {
  51. if (tmp < btns.length) /* boosting */ {
  52. /*
  53. check if the button has no values as "Add" and
  54. not the sender itself, remove it
  55. */
  56. if (btns[tmp].value.indexOf("Add") != 0 && btns[tmp] != q.GetTarget(event)) {
  57. document.body.removeChild(btns[tmp]);
  58. break; /* end the loop */
  59. }
  60. }
  61. }
  62. }
  63. };
Last edited by fatihpiristine; Jan 13th, 2009 at 7:55 pm.
Do a favour, leave me alone
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC