Welcome to TalkGraphics.com
Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 28
  1. #11
    Join Date
    Aug 2004
    Location
    Ukraine
    Posts
    3,904

    Default Re: No support for JavaScript - can it be true?

    I think the problem is different. If this code you are trying to use was taken from the submit button, then simply calling it from anything else than a submit button will not submit the form. It's an internal function of the submit button.
    You can submit form executing following script:
    Code:
    formobject.submit()
    To make it work the way you want, you have to identify the form elemet (it shoud have the "id" or "name" property). Knowing it, you can submit the form from your button.
    Also, the code is too large for the link field so I suggest you add it as a function to the placeholder. For example:
    Code:
    <script type="text/javascript">function my_form_submit(form_name)
    {MM_validateForm('Your Name','','R', 'Your E-mail','','RisEmail', 'Vendor Name','','R', 'Vendor Ref','', 'R', 'Purchase Date','', 'R', 'Installation ID','', 'R', 'Site Code (1)','', 'R', 'Site Code (2)','', 'R', 'Reg Code (1)','', 'R', 'Reg Code (2)','', 'R' );
    document.getElementById(form_name).submit;};</script>
    Then you'll have to put following into your button's link field:
    Code:
    javascript:my_form_submit('formname')
    Where formname has to be replaced with the form's id property.
    John.

  2. #12
    Join Date
    Apr 2009
    Location
    Manchester, UK.
    Posts
    56

    Default Re: No support for JavaScript - can it be true?

    I must admit I'm really struggling to make this work. Could you take a look at the web page please John and see if you can figure out what's wrong?

    At the bottom of the page you'll see the 'old style' Submit button, which is actually a button. Then on the LHS of the page (3rd button down) you'll see the 'new style' Xara button, which is actually a png graphic. Try as I might, I just can't make them do the same thing. The old style button executes this code:-

    Code:
    onClick="MM_validateForm('Your Name','','R', 'Your E-mail','','RisEmail', 'Vendor Name','','R', 'Vendor Ref','', 'R', 'Purchase Date','', 'R', 'Installation ID','', 'R', 'Site Code (1)','', 'R', 'Site Code (2)','', 'R', 'Reg Code (1)','', 'R', 'Reg Code (2)','', 'R' );return document.MM_returnValue
    whereas the new style button executes this code:-

    Code:
    href="javascript:my_form_submit(%27form1%27)" onclick="return(xr_nn());
    which gets translated to this:-

    Code:
    <script type="text/javascript">function my_form_submit(form_name)
    {MM_validateForm('Your Name','','R', 'Your E-mail','','RisEmail', 'Vendor Name','','R', 'Vendor Ref','', 'R', 'Purchase Date','', 'R', 'Installation ID','', 'R', 'Site Code (1)','', 'R', 'Site Code (2)','', 'R', 'Reg Code (1)','', 'R', 'Reg Code (2)','', 'R' };document.getElementById(form_name).submit;};</script>
    The two buttons (almost) do the same thing if the form is completed incorrectly - but if it's completed correctly, the new button doesn't submit the form, nor does it display a message to the user.

    If you just try the two buttons, you'll see the difference immediately. In fact, that'll probably be easier than me trying to explain the differences. You can enter any old data into the form. The only requirement is that the email field must contain something that looks vaguely like an email address - but the other fields can all contain garbage.
    Last edited by johne53; 19 April 2009 at 02:32 PM.

  3. #13
    Join Date
    Aug 2004
    Location
    Ukraine
    Posts
    3,904

    Default Re: No support for JavaScript - can it be true?

    Ok. There are 3 mistakes (one seems to be mine).
    1. You set the Form name to "Form1", while the code I provided requires "id".
    Simply change your form tag to following:
    Code:
    <FORM id = "form1" method = "POST" action = "http://www.avtoolkit.co.uk/cgi-bin/formmail.pl">
    2. You've made a typo in the my_form_submit declaration. It has a "}" instead of ")" after the agrgument list in the call to MM_validateForm.
    3. I have missed brackets in the submit call.
    To fix 2 and 3 replace your current my_form_submit() declaration script with following:
    Code:
    <script type="text/javascript">function my_form_submit(form_name)
    {MM_validateForm('Your Name','','R', 'Your E-mail','','RisEmail', 'Vendor Name','','R', 'Vendor Ref','', 'R', 'Purchase Date','', 'R', 'Installation ID','', 'R', 'Site Code (1)','', 'R', 'Site Code (2)','', 'R', 'Reg Code (1)','', 'R', 'Reg Code (2)','', 'R' );document.getElementById(form_name).submit();};</script>
    Last edited by covoxer; 19 April 2009 at 03:08 PM.
    John.

  4. #14
    Join Date
    Apr 2009
    Location
    Manchester, UK.
    Posts
    56

    Default Re: No support for JavaScript - can it be true?

    That's much better thanks, John. The only problem I have now is this:-

    If the user fills out the form incorrectly, it still gets submitted to me anyway, even though it's got invalid data. You can see that an error dialog gets displayed to the user and at that point, the old code would have aborted the submission process - but the new code carries on regardless.

    FYI, the function MM_validateForm() sets a variable called document.MM_returnValue to be true (if there were no data typos) or false otherwise. Somehow I need the value of that variable to be taken into account when deciding whether or not to submit the form. Is that achievable do you think?

  5. #15
    Join Date
    Aug 2004
    Location
    Ukraine
    Posts
    3,904

    Default Re: No support for JavaScript - can it be true?

    Yes, easily. Here's the new code:
    Code:
    <script type="text/javascript">function my_form_submit(form_name)
    {MM_validateForm('Your Name','','R', 'Your E-mail','','RisEmail', 'Vendor Name','','R', 'Vendor Ref','', 'R', 'Purchase Date','', 'R', 'Installation ID','', 'R', 'Site Code (1)','', 'R', 'Site Code (2)','', 'R', 'Reg Code (1)','', 'R', 'Reg Code (2)','', 'R' );if(document.MM_returnValue)document.getElementById(form_name).submit();};</script>
    John.

  6. #16
    Join Date
    Apr 2009
    Location
    Manchester, UK.
    Posts
    56

    Default Re: No support for JavaScript - can it be true?

    Thanks John, that did the trick. I'd like to learn more about JavaScript. Can you recommend a good book that I could buy (for a beginner, obviously).

  7. #17
    Join Date
    Apr 2009
    Location
    Manchester, UK.
    Posts
    56

    Default Re: No support for JavaScript - can it be true?

    One last question.... one of the original buttons can reset the form. the original code for the button looks like this:-

    Code:
    <INPUT type="reset" name="Reset" value="Reset Form">
    Is there a simlarly simple way to achieve this with JavaScript or do I need to write a special function?

    I tried creating a Xara button and entering javascript:document.reset() in its web properties but that didn't work.

  8. #18
    Join Date
    Aug 2004
    Location
    Ukraine
    Posts
    3,904

    Default Re: No support for JavaScript - can it be true?

    Quote Originally Posted by johne53 View Post
    Code:
    <INPUT type="reset" name="Reset" value="Reset Form">
    Is there a simlarly simple way to achieve this with JavaScript or do I need to write a special function?
    For your current code it's something like this:
    Code:
    javascript:document.getElementById("form1").reset()
    John.

  9. #19

    Wink Re: No support for JavaScript - can it be true?

    Covoxer - you are a javascript genius but are you aware your tendency towards obtrusive javascript is going to drive me into the madhouse???

  10. #20
    Join Date
    Aug 2004
    Location
    Ukraine
    Posts
    3,904

    Default Re: No support for JavaScript - can it be true?

    Quote Originally Posted by richinri View Post
    Covoxer - you are a javascript genius but are you aware your tendency towards obtrusive javascript is going to drive me into the madhouse???
    What is "obtrusive javascript"?
    John.

 

 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •