I'm new to JavaScript and I want to log in to a webpage. This code will take me to the web page but won't sign in. I know it knows the values of username/password because if I do alert(loginForm.elements["username"].value) it displays "someUsername".
I'm not sure how to get these values to be entered into the boxes and hit submit. Any advice helps, thanks!
<script>
function login() {
document.loginForm.action = "http://websiteToLoginTo.com";
document.loginForm.submit();
}
</script>
<body onLoad="login()">
<form name="loginForm" method="post">
<input type="hidden" name="username" value="someUsername">
<input type="hidden" name="password" value="somePassword">
</form>
</body>
The website I'm trying to connect to has this:
<form action="/Authn/UserPassword" method="post" name="loginForm">
<input id="username" name="t_username">
<input id="password" name="t_password">
<input type="submit" name="login" value="Login" class="submit">
</form>
Related
I have form where I need to redirect to a new url, and add the value from the input to the new URL
<form action="https://test.test.com/" method="GET">
<fieldset>
<legend>bftl</legend>
<input type="text" name="trackTrace" id="trackTrace" placeholder="Add your Track & Trace">
<label for="month">Track & Trace</label>
<input type="submit" class="submit" value="Submit">
</fieldset>
</form>
After you have enter the Track & Trace number and pressed the submit button
you shall be redirected to "https://test.test.com/#/TRACK&TRACENUMBER" in a new tab
You need js code like this:
<form action="https://test.test.com/" method="GET" onSubmit="return submitForm()">
<fieldset>
<legend>bftl</legend>
<input type="text" name="trackTrace" id="trackTrace" placeholder="Add your Track & Trace">
<label for="month">Track & Trace</label>
<input type="submit" class="submit" value="Submit">
</fieldset>
</form>
<script>
function submitForm() {
location.href="https://test.test.com/#/TRACK&"+document.getElementById("trackTrace").value;
return false;
}
</script>
let me start by saying that I'm a freshman. I would like to create a form with a button that, when pressed, will generate a page written in an inputa. How to do it? example:
<form action="" method="post">
<!-- a hidden input -->
<input type="hidden" name="a_hidden_input"/>
<!-- a text input -->
<input type="text" name="a_text_input"/>
<!-- submit button -->
<input type="submit" value="Submit"/>
</form>
This is the basic example for getting your data and displaying in the page .
<head>
<script>
function generate() {
debugger
var strText = document.getElementById("txtName").value;
var strText1 = document.getElementById("txtEmail").value;
document.getElementById("p1").innerHTML = strText;
document.getElementById("p2").innerHTML = strText1;
window.location.href = "http://mywebsite.com/home.html";
}
</script>
</head>
<body>
<form>
<input type="text" name="Name" id="txtName" placeholder="Name">
<input type="text" name="Email" id="txtEmail" placeholder="Email">
<input type="button" value="Submit" id="btnSubmit" onclick="generate()">
</form>
<div>
<h1>New Page</h1>
<p id="p1"></p>
<p id="p2"></p>
</div>
</body>
If u use any library like react js or framework like angular with backend technologies like php,nodejs, with databases as sql , mongodb or firebase it will be super easy for u .
I want to pass an email value in a textbox from welcome page to register page in Laravel without using the database. I tried the following code in simple PHP page it works fine but when I use in Laravel 5.7 page it shows an error.
Welcome page
<form method="POST" action="register">
<input type="text" size="40" name="email">
<input type="submit" name="submit">
</form>
Register Page
<form method="POST" action="register">
<input type="email" size="40" name="reg_email" value="<?php echo $_POST['email']; ?>">
<input type="submit" name="submit">
</form>
I want that when I write an email in welcome page form textbox & submit, it shows or display in a register page form email textbox without using Database.
You could send the email as a query string parameter to the registration page.
<!-- Welcome Page (Note the GET method) -->
<form method="GET" action="/register">
<input type="text" size="40" name="email">
<input type="submit" name="submit">
</form>
Make sure you're including the csrf token in your request.
<!-- Registration Page -->
<form method="POST" action="/register">
#csrf
<input type="email" size="40" name="reg_email" value="{{ request('email') }}">
<input type="submit" name="submit">
</form>
try this:
'''' Welcome page: where user would enter the email before proceeding to registration page
<form method="POST" action="{{ route('welcome') }}">
{{ csrf_field() }}
<input type="text" size="40" name="email">
<input type="submit" name="submit">
</form>
'''' Register Page: this is where the email displays inside the input name reg_email
<form method="POST" action="{{ route('register') }}">
{{ csrf_field() }}
<input type="email" size="40" name="reg_email" value="{{ $myemail }}">
<input type="submit" name="submit">
</form>
//the controller collects the email input from the welcome page
public function Welcome(Request $request)
{
$email = $request->input('email');
$data['myemail']=$email; //assign the email variable myemail data to be pass to registration page view
return view('registerpage',$data); //pass the data to the view
}
//Route
Route('/welcome-page','MyController#Welcome')->name('welcome'); //ofcourse the route using name route welcome
I am relatively very new to AngularJS and javascript Please be merciful while answering.
I am trying to create one sample application where I want to nest controllers. MainController which will always be there acting as parent container which will render menu and user name on top if user is logged in. For now I am checking if user is stored in localStorage.
Each page will have its own controller which will do page specific things.
I am stuck at ng-submit and why its not working?
Any help is appreciated.
Index.html
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-route.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-resource.js"></script>
<script src="angularapp.js"></script>
</head>
<body ng-app="myAngularApp">
<div ng-controller="MainController">
<div ng-show="isLoggedIn">Menu</div>
<div ng-view>
</div>
</div>
</body>
login.html
<from ng-submit="login()">
<input type="text" id="username" ng-model="username"></input>
<input type="password" id="password" ng-model="password"></input>
<input type="submit" value="submit" id="submit" ng-submit="login()"></input>
</form>
angularapp.js
angular.module('myAngularApp',['ngRoute','ngResource'])
.config(['$routeProvider',function($routeProvider){
$routeProvider.when('/home',{
controller:'SubController',
templateUrl:'templates/home.html'
})
.when('/login',{
controller:'MainController',
templateUrl:'templates/login.html'
});
}])
.controller('MainController',['$scope','$window','userService',function($scope,$window,userService){
$scope.isLoggendIn=userService.isLoggedIn;
console.log('here I come');
$scope.username='';
$scope.password='';
$scope.login=function(){
alert('Ignored???');
$window.localStorage['myUser']={username:$scope.username,password:$scope.password};
consoel.log('user is logged in now');
};
}])
.controller('SubController',['$scope',function($scope){
$scope.myContent='Contenst to show after logged in';
}])
.service('userService',['$window',function($window){
var self=this;
self.isLoggedIn=function(){
if($window.localStorage['myUser'])
return true;
else
return false;
};
}]);
Please change your code. Seems you have made spelling mistake.
<from ng-submit="submit()">
to:
<form ng-submit="submit()">
Also replace the following code.
<input type="submit" value="submit" id="submit" ng-click="submit()"></input>
No need of ng-submit="login()" in this place type="submit is enought and last one is button not input
<from ng-submit="submit()">
<input type="text" id="username" ng-model="username"></input>
<input type="password" id="password" ng-model="password"></input>
<button type="submit" value="submit" id="submit"></button>
</form>
Edit your code:
<input type="submit" value="submit" id="submit" ng-submit="login()"></input>
Must be as below:
<input type="submit" value="submit" id="submit" ng-click="submit()"></input>
I think there is a problem in your login.html. remove login() because you have submit()
<from ng-submit="submit()">
<input type="text" id="username" ng-model="username"></input>
<input type="password" id="password" ng-model="password"></input>
<input type="submit" value="submit" id="submit"></input>
</form>
I am trying to send someone an email through a form on my website. I want to include a part of my webpage into the email.
To do this I use a hidden field, which I try to fill using a piece of javascript. However due to my lack of knowledge the code doesn't seem to be triggered.
<form action="Emailverstuurd.php" method="POST">
<input id="ExcelForm" type="hidden" name="ExcelForm"/>
<input name="email">
<textarea name="body" rows="10" cols="60"> </textarea>
<script type="text/javascript">
$("#send").submit(function() {
$("#ExcelForm").val($("#myExcelDiv").html());
}
</script>
<input type="submit" name="send" id="send" value="Send Your Message"/>
</p>
</form>
How can I get my javascript code to run?
You can do it like this:
<form action="Emailverstuurd.php" method="POST" onsubmit="submitUpdate()">
<input id="ExcelForm" type="hidden" name="ExcelForm"/>
<input name="email">
<textarea name="body" rows="10" cols="60"> </textarea>
<script type="text/javascript">
function submitUpdate()
{
$("#ExcelForm").val($("#myExcelDiv").html());
}
</script>
<input type="submit" name="send" id="send" value="Send Your Message"/>
</p>
</form>
Just add an onsubmit handler to your form field give it a function and just put you value update in that function...I don't see #myExcelDiv I'm assuming that is defined somewhere else in your code?