943,640 Members | Top Members by Rank

Ad:
Jan 12th, 2009
0

submit once button

Expand Post »
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 ?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
runrunforest is offline Offline
1 posts
since Jan 2009
Jan 12th, 2009
0

Re: submit once button

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <form>
  2. <input type="submit" disabled="disabled">
  3. </form>
Reputation Points: 85
Solved Threads: 64
Practically a Master Poster
sillyboy is offline Offline
686 posts
since Mar 2007
Jan 13th, 2009
0

Re: submit once button

> 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.
Super Moderator
Featured Poster
Reputation Points: 3233
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,871 posts
since Jun 2006
Jan 13th, 2009
0

Re: submit once button

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.

javascript Syntax (Toggle Plain Text)
  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.
Reputation Points: 6
Solved Threads: 19
Posting Whiz in Training
fatihpiristine is offline Offline
283 posts
since Sep 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: Are graphically connected nodes possible, and can they be altered by input?
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Refresh the page to all in the site on click





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC