A simple function is not working. Must be something weird ... but what it is ???

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kigoobe
    New Member
    • May 2007
    • 67

    A simple function is not working. Must be something weird ... but what it is ???

    I am having a very weird issue here, a simple form submit not working. Trying for several hours now ... must be something stupid ... help appreciated.

    First, the html -
    Code:
    <form id="formFinale" method="post" action="noscript.php" enctype="application/x-www-form-urlencoded">
    
       <div class="myStyle">Votre nom ? <input type="text" size="36" name="ouchocolat" id="ouchocolat" value="" /></div>
    	
       <div class="myStyle">J’ai lu et je suis d’accord avec les <a href="conditions.html"  onclick="this.target='_blank'">conditions générales de vente</a> : <input type="checkbox" name="agree" id="agree" /></div>
    
       <div class="rightContent right">
          <div class="center"><input type="button" class="button" value="Paiement en ligne" onclick="ifagree('agree','formFinale','getForm.php?ph=3&action=bank');" /></div>
    
       </div>
    
       <div class="r">
          <div class="center"><input type="button" class="button" value="Paiement par cheque" onclick="ifagree('agree','formFinale','getForm.php?ph=3&action=check');" /></div>
    
       </div>
    <div class="clearer"></div>
    </form>
    Then - the javascript.
    Code:
    function multiSubmit(formId,url) {
    	document.getElementById(formId).action=url;
    }
    
    function ifagree(id,formId,url) {
    	if (document.getElementById(id).checked == false) {
    		alert('Veuillez accepter les condition général de vente.');
    		return false;
    	} else {
    		if(url) {
    			return multiSubmit(formId,url);
    		} else {
    			return true;
    		}
    	}
    }
    It seems to be getting executed in case I change the line from document.getEle mentById(formId ).action=url; to alert(document. getElementById( formId).action) ;

    I can see that I am getting the right action in the alert. However, as it stands now, it's simply not working. :(:(:(

    What's happening when I tell that it's not working? Well, problem is nothing really is working. No error icon in IE, no error in FF error console, nothing moves as I click on either of these buttons !

    Joining the two functions to one doesn't change things either ...

    Code:
    function ifagree(id,formId,url) {
    	if (document.getElementById(id).checked == false) {
    		alert('Veuillez accepter les condition général de vente.');
    		return false;
    	} else {
    		if(url) {
    			document.getElementById(formId).action=url;
    		} else {
    			return true;
    		}
    	}
    }
    Thanks for having a look.
    Regards.
  • Dasty
    Recognized Expert New Member
    • Nov 2007
    • 101

    #2
    Setting action property does not submit form. You have to submit it somewhere.

    Code:
    document.getElementById(formId).submit();

    Comment

    • kigoobe
      New Member
      • May 2007
      • 67

      #3
      thanks Dasty, you are a genious :)

      Comment

      Working...