Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form information fetching problem

    Hello everyone,

    I've got a problem while trying to fetch some informations from multiple forms in the same page.
    What I'm trying to do with this code is fetching informations from the multiple forms on my page and checking if the information is the information I need.
    If so, I take this information and add it into a javascript generated form that I submit once every form in the page have been taken care of.

    It's the only way I found to 'submit' multiple forms at the same time.

    Everything was fine until I decided to give the user the option to add more forms on the page by clicking on a button (the form is then generated by javascript and appended on the page).

    There seems to be a problem when checking these particular forms, the script doesn't seem to recognize the value of the radio button (wich is add_question_faq) and never ever enters in this case.
    Code:
    case "add_question_faq":
            alert ("pourquoi, ho, pourquoi")
            if (mesForms[cpt].question.value=="" || mesForms[cpt].answer.value==""){
            chaineModif+="StopSendRightNow"
            }
            break;
    Except when the commentarised
    Code:
    //for (h=0;h<mesForms[cpt].elements.length;h++){
    //alert (mesForms[cpt].elements[h].name)
    //}
    ain't commentarised.

    Any Idea why a simple alert changes the behavior of the function?


    Here's the said function:

    Code:
     function select_forms_faq(){
    
            var chaineModif=""
            var mesFormsModif=new Array();
            var mesForms=document.getElementsByTagName("form");
            
            for (cpt=0;cpt<mesForms.length;cpt++){
    
            //for (h=0;h<mesForms[cpt].elements.length;h++){
            //alert (mesForms[cpt].elements[h].name)
            //}
    
            if (mesForms[cpt].action.length!=0 && mesForms[cpt].action.length!=undefined){
    
            for (k=0;k<mesForms[cpt].action.length;k++){
    
            if (mesForms[cpt].action[k].checked==true){
            
            switch (mesForms[cpt].action[k].value){
            
            case "delete":
            chaineModif+="<input type=\'text\' name=\'delete_"+mesForms[cpt].id_question.value+"\' value=\'"+mesForms[cpt].id_question.value+"\' />";
            break;
            case "save_changes_question":
            chaineModif+="<input type=\'text\' name=\'update_question_faq_"+mesForms[cpt].id_question.value+"\' value=\'id"+mesForms[cpt].id_question.value+"question"+mesForms[cpt].question.value+"answer"+mesForms[cpt].answer.value+"\' />"
            break;
            case "save_changes_cat":
            chaineModif+="<input type=\'text\' name=\'update_cat_faq_\' value=\'id"+mesForms[cpt].id_cat.value+"category"+mesForms[cpt].cat.value+"\' />"
            break;
            case "add_question_faq":
            alert ("pourquoi, ho, pourquoi")
            if (mesForms[cpt].question.value=="" || mesForms[cpt].answer.value==""){
            chaineModif+="StopSendRightNow"
            }
            break;
            }
            }
            }
            }
            }
            if (chaineModif!="" && chaineModif.indexOf("StopSendRightNow")==-1){
            var formFinal=document.createElement("form")
            with(formFinal){
            method="POST"
            action=""
            name="formFinal"
            id="formFinal"
            style.display="none"
            }
            chaineModif+="<input type=\'hidden\' name=\'submit_changes_faq\' value=\'submit_changes_faq\' />"
            document.getElementById("wpbody-content").appendChild(formFinal)
            document.getElementById("formFinal").innerHTML=chaineModif
            formFinal.submit();
            return false
            }
            else{
            return false
            }
        }

  • #2
    New to the CF scene
    Join Date
    Jul 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The code also works if I wait something like 5 minutes.

    What's going on there?


  •  

    Tags for this Thread

    Posting Permissions

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