473,396 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

67
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 -
Expand|Select|Wrap|Line Numbers
  1. <form id="formFinale" method="post" action="noscript.php" enctype="application/x-www-form-urlencoded">
  2.  
  3.    <div class="myStyle">Votre nom ? <input type="text" size="36" name="ouchocolat" id="ouchocolat" value="" /></div>
  4.  
  5.    <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>
  6.  
  7.    <div class="rightContent right">
  8.       <div class="center"><input type="button" class="button" value="Paiement en ligne" onclick="ifagree('agree','formFinale','getForm.php?ph=3&action=bank');" /></div>
  9.  
  10.    </div>
  11.  
  12.    <div class="r">
  13.       <div class="center"><input type="button" class="button" value="Paiement par cheque" onclick="ifagree('agree','formFinale','getForm.php?ph=3&action=check');" /></div>
  14.  
  15.    </div>
  16. <div class="clearer"></div>
  17. </form>
  18.  
Then - the javascript.
Expand|Select|Wrap|Line Numbers
  1. function multiSubmit(formId,url) {
  2.     document.getElementById(formId).action=url;
  3. }
  4.  
  5. function ifagree(id,formId,url) {
  6.     if (document.getElementById(id).checked == false) {
  7.         alert('Veuillez accepter les condition général de vente.');
  8.         return false;
  9.     } else {
  10.         if(url) {
  11.             return multiSubmit(formId,url);
  12.         } else {
  13.             return true;
  14.         }
  15.     }
  16. }
  17.  
It seems to be getting executed in case I change the line from document.getElementById(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 ...

Expand|Select|Wrap|Line Numbers
  1. function ifagree(id,formId,url) {
  2.     if (document.getElementById(id).checked == false) {
  3.         alert('Veuillez accepter les condition général de vente.');
  4.         return false;
  5.     } else {
  6.         if(url) {
  7.             document.getElementById(formId).action=url;
  8.         } else {
  9.             return true;
  10.         }
  11.     }
  12. }
  13.  
Thanks for having a look.
Regards.
Nov 30 '07 #1
2 1321
Dasty
101 Expert 100+
Setting action property does not submit form. You have to submit it somewhere.

Expand|Select|Wrap|Line Numbers
  1. document.getElementById(formId).submit();
Nov 30 '07 #2
kigoobe
67
thanks Dasty, you are a genious :)
Dec 1 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

27
by: Brian Sabbey | last post by:
Here is a first draft of a PEP for thunks. Please let me know what you think. If there is a positive response, I will create a real PEP. I made a patch that implements thunks as described here....
31
by: da Vinci | last post by:
OK, this has got to be a simple one and yet I cannot find the answer in my textbook. How can I get a simple pause after an output line, that simply waits for any key to be pressed to move on? ...
1
by: robert | last post by:
hi! I want to have a custom button change appearance when pressed and then call a function and change back to its original appearance when released. here's what i have now, which works mostly....
3
by: Jim Heavey | last post by:
Hello I am working through a littel tutorial on XSL and I have a "simple" question. I am wanting to build a table with headings of the lement names. The tutorial show that I am to use the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.