Posted By

1man on 10/01/08


Tagged

clear submit radio donate


Versions (?)

jQuery radio button donate submit


 / Published in: JavaScript
 

This snippet is useful on donate forms. If you have a radio button for other value, then this will clear the current value in the text input box, and attach the user in putted value to the other radio button.

  1. //Clear the value in the text form when you click other
  2. $("#other").click(function(){
  3. $("#inputAmount").attr("value", "").focus().select();
  4. });
  5.  
  6. $("#donateBox form").submit(function(){
  7. //Check to see if the radio button is checked
  8. if($("#other").is(":checked")){
  9. //Take value from the text box
  10. var ourValue = $("#inputAmount").attr("value");
  11. //Check to see if we have a value
  12. if(ourValue ==="" || ourValue ==="0"){
  13. ourValue = "5";
  14. }
  15. //Add it to the radio button
  16. $("#other").attr("value", ourValue);
  17. } else {
  18. return;
  19. }
  20. });

Report this snippet  

You need to login to post a comment.