0

Hi i have a HTML form like this:

 <form id="msform" action="https://forms.hubspot.com/uploads/form/v2/5435007/bb741987-d401-482b-86b3-13ebf0405ec4" method="post">
  <img class="logo" src="https://cdn2.hubspot.net/hubfs/5435007/ZenMaster/cos-logo.jpg" alt="COS logo">
  <input type="email" id="mail" name="email" value="{{request.query_dict.email}}">
   <input type="hidden" id="something" name="hs_context" value="">
 <fieldset>
    <legend><span class="number">4</span>Section 4 (4/5)</legend>
     <h2>Do you have a COS Account Manager? (Your account manager is your primary sales contact at COS)</h2>       
     <label>1. My account manager is exceptional at providing solutions to my business problems:</label>
      <input type="radio" id="radio_s4_01" value="Strongly Disagree" name="my_account_manager_is_exceptional"><label for="radio_s4_01" class="light">Strongly Disagree</label>
      <input type="radio" id="radio_s4_02" value="Slightly Disagree" name="my_account_manager_is_exceptional"><label for="radio_s4_02" class="light">Slightly Disagree</label>
          <input type="radio" id="radio_s4_03" value="Disagree" name="my_account_manager_is_exceptional"><label for="radio_s4_03" class="light">Disagree</label>
          <input type="radio" id="radio_s4_04" value="Neutral" name="my_account_manager_is_exceptional"><label for="radio_s4_04" class="light">Neutral</label>
          <input type="radio" id="radio_s4_05" value="Slightly Agree" name="my_account_manager_is_exceptional"><label for="radio_s4_05" class="light">Slightly Agree</label>
          <input type="radio" id="radio_s4_06" value="Strongly Agree" name="my_account_manager_is_exceptional"><label for="radio_s4_06" class="light">Strongly Agree</label>

         <label for="bio">7. Other:</label>
       <textarea id="bio" name="other_section_5"></textarea> <br>
       <input type="button" name="previous" class="previous action-button" value="Previous" />
       <input type="button" name="next" class="next action-button" value="Next" />
     </fieldset>

        <!---------------------------------------- Section 5 --------------------------->
  <fieldset>
     <legend><span class="number">6</span>Section 6 (6/6)</legend>
    <label for="bio">1. How likely are you to recommend COS to a colleague or friend?</label>
     <textarea id="bio" name="how_likely_are_you_to_recommend"></textarea>

        <label for="bio">2. What are your reasons for giving that score?</label>
     <textarea id="bio" name="what_are_your_reasons_for_giving_that_score"></textarea>

        <label for="bio">3. What ONE THING (if any) should COS START doing right now?</label>
     <textarea id="bio" name="what_one_thing_if_any_should"></textarea>

        <label for="bio">4. What ONE thing (if any) should COS STOP doing right now?</label>
     <textarea id="bio" name="one_thing_if_any_should_cos_stop"></textarea>

        <label for="bio">5. What is COS' single greatest STRENGTH?</label>
     <textarea id="bio" name="cos_single_greatest_strength"></textarea>

        <label for="bio">6. What is COS' single greatest WEAKNESS?</label>
     <textarea id="bio" name="cos_single_greatest_weakness"></textarea>

        <label for="bio">7. Lastly, do you have any advice or feedback to give to the COS General Manager?</label>
     <textarea id="bio" name="lastly_do_you_have_any_advice"></textarea>
    <input type="button" name="previous" class=" previous action-button" value="Previous" />
    <input type="submit" value="Submit" class="action-button" />
  </fieldset>

</form>

and i have a piece of javascript that create multi-step form, however i was trying to make it redirecting to another page after the subsmission but im stuck, i tried to use window.location but didnt work, here is the entire js:

$(function() {

//jQuery time
var current_fs, next_fs, previous_fs; //fieldsets
var left, opacity, scale; //fieldset properties which we will animate
var animating; //flag to prevent quick multi-click glitches

$(".next").click(function(){
    if(animating) return false;
    animating = true;

    current_fs = $(this).parent();
    next_fs = $(this).parent().next();

    //activate next step on progressbar using the index of next_fs
    $("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");

    //show the next fieldset
    next_fs.show(); 
    //hide the current fieldset with style
    current_fs.animate({opacity: 0}, {
        step: function(now, mx) {
            //as the opacity of current_fs reduces to 0 - stored in "now"
            //1. scale current_fs down to 80%
            scale = 1 - (1 - now) * 0.2;
            //2. bring next_fs from the right(50%)
            left = (now * 50)+"%";
            //3. increase opacity of next_fs to 1 as it moves in
            opacity = 1 - now;
            current_fs.css({'transform': 'scale('+scale+')'});
            next_fs.css({'left': left, 'opacity': opacity});
        }, 
        duration: 800, 
        complete: function(){
            current_fs.hide();
            animating = false;
        }, 
        //this comes from the custom easing plugin
        easing: 'easeInOutBack'
    });
});

$(".previous").click(function(){
    if(animating) return false;
    animating = true;

    current_fs = $(this).parent();
    previous_fs = $(this).parent().prev();

    //de-activate current step on progressbar
    $("#progressbar li").eq($("fieldset").index(current_fs)).removeClass("active");

    //show the previous fieldset
    previous_fs.show(); 
    //hide the current fieldset with style
    current_fs.animate({opacity: 0}, {
        step: function(now, mx) {
            //as the opacity of current_fs reduces to 0 - stored in "now"
            //1. scale previous_fs from 80% to 100%
            scale = 0.8 + (1 - now) * 0.2;
            //2. take current_fs to the right(50%) - from 0%
            left = ((1-now) * 50)+"%";
            //3. increase opacity of previous_fs to 1 as it moves in
            opacity = 1 - now;
            current_fs.css({'left': left});
            previous_fs.css({'transform': 'scale('+scale+')', 'opacity': opacity});
        }, 
        duration: 800, 
        complete: function(){
            current_fs.hide();
            animating = false;
        }, 
        //this comes from the custom easing plugin
        easing: 'easeInOutBack'
    });
});

$(".submit").click(function(){
  return false;
})
//end of line 
});

can someone suggest a good solution for this? im not using any serverside code to execute anything, just simply use frontend script to handle the task

Zen
  • 11
  • 1
  • From what you showed us, you are submitting to a third-party URL. So unless you use AJAX, you need certain degree of server-side code to make the redirect. – yqlim Sep 18 '19 at 01:30
  • okay in that case, have you got any code suggestion that i can have a look? – Zen Sep 18 '19 at 01:41
  • You can take a look [here](https://stackoverflow.com/questions/1960240/jquery-ajax-submit-form) or simply google it. It's very thoroughly covered. However, you need to make sure the third-party endpoint properly support ajax submission. – yqlim Sep 18 '19 at 01:44

1 Answers1

0

Change the action URL of a form :

$("#msform").attr("action", "<<<<new action>>>>>");
$("#msform").submit();