javascript - how to submit a CFform and change its action attribute after the new page load? -
i trying have cfform users can input , search result on different website requires log in obtain access desire results. other website open in pop or new page user credentials logged in , display results user input in cfform or cfform or form not ensure how should done. provide quick way search results in different site site while skipping log in progress users of site contains results.
so far have working cfform opens www.somewebsite.com user logged in looks
<cfform action="https://www.somewebsite.com/login.php" method="post" id="ud_form"> <cfinput type="hidden" name="email" value="#email#" /> <cfinput type="hidden" name="password" value="#password#" /> <cfinput type="hidden" name="source" value="#source#" /> </cfform> <script type="text/javascript"> document.getelementbyid('ud_form').submit(); </script>
the problem having haven't find way change action attribute after login process completes. example, once log in happens cfform action attribute should set new url + input values of cfform (https://www.somewebsite.com/cp.php?addr="+form_address+"&unit="+form_unit) , submitted. have done ton of research , not find solution this.
i have tried include cfinput tags inside above cfform , use javascript function trigger action attribute change after form submitted. pressing submit button fail trigger action without report script error in console. code used shown below.
<cfform action="https://www.somewebsite.com/login.php" method="post" id="ud_form" onsuccess="show_results();"> <cfinput type="hidden" name="email" value="#email#" /> <cfinput type="hidden" name="password" value="#password#" /> <cfinput type="hidden" name="source" value="#source#" /> address: <input id="address" type="text" name="address" placeholder="enter address" size=40><br/><br/> unit #: <input id="unit" type="text" name="unit" placeholder="enter unit" size=40><br/><br/> <input id="submit" type="button" value="search"> </cfform> <script type="text/javascript"> $("#submit").click(function(){ $("#ud_form").submit(); }); function show_results() { var form_address =$("#address").val(); form_address = form_address.split(' ').join('+'); var form_unit = $("#unit").val(); form_unit =form_unit.split(' ').join('+'); var url = "https://www.somewebsite.com/cp.php?addr="+form_address+"&unit="+form_unit; $('#ud_form').attr('action',url); $("#ud_form").submit(); }
any or suggestions appreciated!
once submit html form, browser going move away code in case - it's going start interacting somewebsite.com
i think you'll want submit form , take form fields , cfhttp them www.somewebsite.com, , using results returned populate page/dialog/pop-up data fetched.
otherwise, you're sending user off secondary site , navigating them away yours.
Comments
Post a Comment