Advanced Search

Results 1 to 6 of 6

Thread: Multiple form instance of Form dependency not working

  1. #1
    Join Date
    Oct 2006
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Multiple form instance of Form dependency not working

    1) Script Title: Form Dependency Manager

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...dependency.htm

    3) Describe problem:

    Hi there,

    <script type="text/javascript">
    window.onload = function() {
    setupDependencies('weboptions'); //name of form(s). Seperate each with a comma (ie: 'weboptions', 'myotherform' )
    };
    </script>
    I'm trying to get this script to work with two forms. However, no matter what I do, I can only get it working with one or the other. Never both.

    I've tried:

    <script type="text/javascript">
    window.onload = function() {
    setupDependencies('form1','form2');
    };
    </script>
    <script type="text/javascript">
    window.onload = function() {
    setupDependencies('form1', 'form2' );
    };
    </script>
    &
    <script type="text/javascript">
    window.onload = function() {
    setupDependencies('form1',
    'form2');
    };
    But only the first form listed works. If I delete form1 and put form2 in it's place, form2 begins using the script properly. I just can't get both to use the script.

    Could someone tell me what I'm doing wrong?

    thanks,
    json
    </script>

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,913
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Hmm, there's no reason it shouldn't work with both unless there's something odd going on with your forms. Can we see the page?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Oct 2006
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi there Twey, and thanks for the reply,

    here's the html being generated:

    Code:
    <html>
    <head>
    <title>Briarfield Cafe <~> Employment Application</title>
    <script src="FormManager.js">
    /****************************************************
    * Form Dependency Manager- By Twey- http://www.twey.co.uk
    * Visit Dynamic Drive for this script and more: http://www.dynamicdrive.com
    ****************************************************/
    </script>
    
    <script type="text/javascript">
    window.onload = function() {
        setupDependencies('employment_app', 'verify');
      };
    </script>
    
    <script type="text/javascript">
    
    /***********************************************
    * Textarea Maxlength script- � Dynamic Drive (www.dynamicdrive.com)
    * This notice must stay intact for legal use.
    * Visit http://www.dynamicdrive.com/ for full source code
    ***********************************************/
    
    function ismaxlength(obj){
    var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
    if (obj.getAttribute && obj.value.length>mlength)
    obj.value=obj.value.substring(0,mlength)
    }
    
    </script>
    
    <STYLE TYPE="text/css">
    <!--
    div.error {
      border: 2px dashed #333;
      padding: 10px;
      background-color: #ffe;
      }
    -->
    </STYLE>
    
    </head>
    <body>
    
    <center><h1>Your application is being validated</h1></center><br><br><form name='verify' method='post' action='application.php?action=verify'>
    		<div class='error'><b><font color='red'>Error:</font></b> No response:<br>
    		Are you eligible to work in the United States?<br>(<INPUT TYPE='radio' NAME='able_work' VALUE='yes'>Yes) or (<INPUT TYPE='radio' NAME='able_work' VALUE='no'>No)</div>
    		<br>
    
    		<input type='hidden' name='verify' value='1'>
    		<div class='error'><b><font color='red'>Error:</font></b> No response:<br>
    		If you are under age 18, do you have an employment/age certificates?<br>
    		(<INPUT TYPE='radio' NAME='work_cert' VALUE='yes'>Yes) or (<INPUT TYPE='radio' NAME='work_cert' VALUE='no'>No)</div>
    		<br>
    
    		<input type='hidden' name='verify' value='1'><div class='error'><b><font color='red'>Error:</font></b> No response:<br>
    		Have you been convicted of or pleaded no contest to a felony within the last five years?
    		<br>
    		<label>Yes<input type='radio' name='conviction' value='con_yes'></label>
    		<label>No<input type='radio' name='conviction' value='con_no'></label>
    		<label style='margin-bottom: 1em; padding-bottom: 1em; border-bottom: 3px silver groove;'><input type='hidden' class='DEPENDS ON os BEING linux OR os BEING windows'></label>
    		<label><br>
    
    		<br>
    		Please Explain:<br>
    		<textarea name='convict_ex' cols=60 rows=10 maxlength="500" onkeyup="return ismaxlength(this)" class='DEPENDS ON conviction BEING con_yes'></textarea><br>
    		</label></form></body></html>
    This page is being generated by PHP. The head content is being shared by both pages(and forms), so if one works, logic would dictate that the head content wouldn't be the problem for the second form which leads me to believe that I've messed up in the body.

    Problem is though that I simply copied & pasted the form element from the working form to the non-working one. I didn't intentionally change anything.

    Any light you could shed would be greatly appreciated.

    thanks,
    json

  4. #4
    Join Date
    Oct 2006
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi there twey,

    I fixed it with a PHP if/else. It wasn't working with more than one form listed.

    thanks,
    json

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,913
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    <label style='margin-bottom: 1em; padding-bottom: 1em; border-bottom: 3px silver groove;'><input type='hidden' class='DEPENDS ON os BEING linux OR os BEING windows'></label>
    Uh, that's from the demo and bears no relevance to your form.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    Oct 2006
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks very much for that, but I would also have to say that it bears no relevence to my problem, either.

    Uh,
    json

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
  •