I am using nested ng-includes in my app . Outer one is login screen for different application and inner ng-include includes 2 templates . My login screen is designed in two steps . First email will be checked then the password .
I am having issue in form post . In second template password one when the form is posted , suppose if password not matched then it shows error but my ng-include template is reset to first one . I am not using ng-submit instead action attribute is define which post the form .
Here is my code
Second ng-include
<div ng-include="currTemplate" class="slide"></div>
$scope array contains templates
$scope.templates = ['/Content/app/templates/AddAccount.html', '/Content/app/templates/Login.html'];
When controller loads it is set to 0
$scope.currTemplate = $scope.templates[0];
I have a form in Login template
<form name="form" method="post" action="{{model.loginUrl}}">
in which action attribute is define . When this form posted and results in error my template is changed to AddAccount.html and error is shown. I can't use ng-submit to post form need help ?
Looks like you are doing a full page reload with the post. This will reset all your client side values to their defaults. You need to submit the form as an XHR (ala ng-submit) or return data from the failure that let's you adjust the correct template to show.
Related
I have searched a lot but did not find any answer...
My Question is, let's say I have a random page and user click on the download button to download a file, and the html in the button is:
<form action="http://seconddomain.com/thanks-for-downloading/" target="_blank" method="post">
<input type="hidden" name="FileID" value="dYnte-m9bZ4">
<div align="center">
<input alt="Download Movie" src="image url here" type="image">
</div>
</form>
This data is submitted to the next page with post method using in the form, as you can note the value is defined as "dYnte-m9bZ4"
In this case, this value is the file download link, eg: downlaodfile.com/dYnte-m9bZ4
I want that when this data is submitted with post method on the next page there should be some PHP code that will automatically attach the defined value to the server URL/link as downlaodfile.com/dYnte-m9bZ4 and the user will be automatically redirected to the download page.
If this is not possible with post form method, then please suggest any other method...
Please tell me how can I do it.
Thanks...
Add this line,from where you want to redirect in your post handler php file.
$var = $_POST["FileID"];
// do input validation ,type-check etc on $var.
header("Location: http://downlaodfile.com/".$var);
I have done same thing of redirecting after form submission
you can check my code # Bitbucket line no 459 of link
Never use user input directly. Never.
Sanitize and validate before using user input.
Escape data when necessary (when data switches execution contexts).
Note: This does not include error handling. This is just a skeleton.
$filteredPost = filter_input_array(INPUT_POST, $filterRulesArray); //Sanitize
$validatedPost = filter_var_array($filterdPost, $validationRulesArray) //Validate
$fileId = urlencode($validatedPost['FileID']); //Potentially, an important step in this case.
header("Location: http://downloadfile.com/{$fileId}");
PHP Manual: filter_input_array()
PHP Manual: filter_var_array()
PHP Manual: urlencode()
My Form Works Successfully But in website URL it only Shows the address to a Form.I have multiple Pages in which the Form button shown.All I want when a user click on The Form for Page A for that Particular page it should shown as
"www.form.com?test=page A" - this should displayed on website URL
or when the Form is submitted the receiver should view that this form coming from Page A..In the Form field I hidden this fields name 'Test' so the user cannot see it but only the receiver can view it that its coming from Page A
On my Html code I have redirected to the Build in Form.
Here is my java script code
<script type="text/javascript" src="http://test.com/form/y.php/test2"></script><no1script>Online Form - </no1script>
How to show it to my Website URL
I understand your question as "How can I redirect with a specific GET parameter?", correct me if I'm wrong.
The solution for that would be quite simple: Append the GET parameter to the forms action:
<form action="target.php">
gets
<form action="target.php?test=page_a">
so that on target.php if you evaluate the GET values, test has the value page_a.
If you're trying to hide the post data, you can try something like:
<form action="https://test.com/forms/discount" style="display:none">
<input type="text" name="couponCode" value="secret">
<input id="myform" type="submit">
</form>
<script>
document.querySelector("#myform").click();
</script>
Note: This won't stop any web ninjas, so you should think of something else, like web tokens that function sortta like private public keys.
I am building an AngularJS application that includes modal windows which contain forms and are loaded into the DOM asynchronously (when the appropriate button is clicked). The forms work fine, but I cannot properly check if they are valid. Here's an example:
HTML
<div ng-app="myapp" ng-controller="MyCtrl">
<form novalidate name="myform" ng-submit="submitForm(myform)">
<input type="text" required ng-model="myname" />
</form>
</div>
JavaScript
var app = angular.module('myapp', []);
app.controller("MyCtrl", function($scope) {
$scope.submitForm(form) {
if(form.$valid) {
// Do http stuff here
}
};
});
If this form is loaded asynchronously, the form variable has value NaN and form.$valid is undefined. However, if I load it with the rest of the page, it works fine. Does anyone know how to force AngularJS to populate the scope variable for the form? Thanks!
When you include a form using ng-include a childScope is created. The parent and the childScope cant access eachothers scopes. Therefore the .$valid comes up empty.
I had a similiar issue the other day and got a working solution that suited me in this thread:
AngularJS $setValidity on childScope form
I have a basic question here not been able to get it right....
I have a ColdFusion form abc.cfm and on submit posts to
<form name="MyForm"
method="post"
action="abc_action.cfm?vempnum=
<cfoutput>#qGetemplookup.emplid#&year=#form.year#</cfoutput>"
Now I have a textbox and a select box and I'm able to get the emplid value on the action page in the url but not able to get the year (which is the select box value)...not sure what I'm doing wrong here. Any help is appreciated.
If I understand the question correctly, you are trying to access form.year prior to actually submitting the form that the year input exists in. This won't work because the form scope will only be populated once the form has actually been submitted.
Trying to add form.year to the URL of the action is actually redundant, because when you do POST the form, the value selected for year will be available to you as part of the form struct.
ColdFusion renders the action when the page is rendered to the screen. So, #form.year# is being populated with whatever it is set to when the page loads.
You're submitting via POST method, so form.year is automatically populated when the processing page (abc_action.cfm) receives the form submission.
Wrap your form tag with CFOUTPUT and place the variable in there.
For example:
<cfoutput>
<form name="MyForm" method="post" action="abc_action.cfm?vempnum=#qGetemplookup.emplid#&year=#form.year#">
</form>
</cfoutput>
i am trying to submit a hidden form that contain the per_page and current_page details as a param values for paginating the search results , but the same view page contain the search form also . but while submitting the hidden form by using .submit() method in AJAX for paginating the search results i am getting conflicts between these 2 forms . could any one please tell what we need to care about while using 2 forms in one view page in Rails .
No you can have n number of forms, but they should not be nested.
your html should be liek foloowing
<form id="form_1">
</form>
<form id="form_2">
</form>
|
|
|
<form id="form_n">
</form>
and to submit form_1 using jquery use .submit method of jquery as following
$('#form_1').submit()
remove nesting of forms and if nessary that it will see under another use iframe for inner one