How can I submit a form to a new tab in my chrome extension - google-chrome-extension

I am working on a Google chrome extension. the idea is that I enter my username and password, click submit and have a new tab open with my website, which will then pick up the submitted form and log me in.
I have managed to open my website in a new tab, but can not get it to pick up the form.

You can use OnClick event in submit button:
<input type="submit" value="submit" onclick="this.form.target='_blank';return true;">

You can create an HTML form in your popup.html as follows:
<form name="input" action="http://example.com/login.php" method="get">
Username: <input type="text" name="user">
Password: <input type="password" name="password">
<input type="submit" value="Submit"></form>
And in the script of your website you can check if the parameters and have been passed, and if correct then create redirect them to the DashBoard on your site, otherwise show them the login page to enter the correct credentials

Since you've got your website loaded, try using jquery to select the textbox and enter a value.
The following selects the where the input is, then finds the input I want, then finally sets the value inside of that box.
$("td[data-key='sku']").find("input.tb-input").val('some text here')
In the jquery code above, the html would look something like this:
<td data-key='sku'>
<input class=tb-input/>
</td>

Related

How to Remember Pass Values Without Exposing To HTML? (NodeJS/ejs)

I tried to Google search but I did not even know what to search for!
My current problem is: say I have a customer order an item, it will show in his list of orders and he can then edit the order in the future by clicking a button next to the order.
Currently the button submits a hidden form which contains all information needed to identify a particular order and this form is passed into the edit order page through a post request. Although the form is hidden, when page source is viewed the information will still be accessible by the user.
How do I avoid exposing the information to the user? I.e do everything in the backend.
<form method="POST" action="/edit_order">
<input type="hidden" name="owner_email" value=<%=all.owner_email %>>
<input type="hidden" name="owner_email" value=<%=all.transactionId %>>
<input type="hidden" name="start_date" value=<%=moment(all.start_date).format() %>>
<input type="hidden" name="end_date" value=<%=moment(all.end_date).format() %>>
<button type="submit" class="btn btn-secondary">Change this order</input>
</form>

Node.js Getting values from html and using req.body.<name>

I am trying to retrieve multiple values from HTML and make use of it using req.body..
I am able to do this via message: req.body.message
<form id="message-form" class="input-group input-group-lg" style="">
<input type="text" name="message" class="form-control" aria-label="Large" aria-describedby="inputGroup-sizing-sm">
<div class="input-group-prepend">
<button class="btn btn-primary">Send</button>
</div>
</form>
However, I would like to retrieve the values from elements that are not inside the e.g <span id="item" style="font-weight:bold"> </span>
The reason is that when I load the page, it renders these values dynamically (retrieved from database). When I want to do a POST, I would like to make use of these values that have been rendered previously.
Is there a way to do this?
Many thanks.
Forms don't submit data that does not appear inside a form control.
So you can either:
Store the data somewhere in the server (such as in a session) where you can read it back on a subsequent request (watch out for race conditions!) or
Put the data in a form control instead of or as well as in the span. (Possibly using a hidden input).

How to create Quiz in modx

I am new to modx and I have to create multipage quiz in my website.
Any suggestion will be helpfull.
While there are more than one way to achieve this, a combination of FormIt
and FormItRetriever extras might just be what you need. FormIt handles the processing of your quiz forms, which includes saving the data in the cache or on the database as a JSON object. And, as the name suggests, FormItRetriever allows you to retrieve previously saved form data on a subsequent page.
Here's a quick example adapted from FormIt's docs:
Page 1
[[!FormIt?
&submitVar=`go`
&hooks=`spam,redirect`
&store=`1`
&redirectTo=`id-of-next-page`
]]
<form action="[[~[[*id]]]]" method="post">
<input type="hidden" name="nospam" value="" />
<label for="qzq1">Quiz question 1: [[!+fi.error.qzq1]]</label>
<input type="text" name="qzq1:required" id="qzq1" value="[[!+fi.qzq1]]" />
<label for="qzq2">Quiz question 2: [[!+fi.error.qzq2]]</label>
<input type="text" name="qzq2:required" id="qzq2" value="[[!+fi.qzq2]]" />
<label for="qzq3">Quiz question 3: [[!+fi.error.qzq3]]</label>
<textarea name="qzq3:stripTags" id="qzq3" cols="55" rows="7">[[!+fi.qzq3]]</textarea>
<br />
<input type="submit" name="go" value="Next" />
</form>
The &store property tells FormIt to store the data in the cache for retrieval using the FormItRetriever snippet.
The &redirectTo property is the ID of your next page. FormIt will use the redirect hook, specified in the &hooks property, to redirect the user when they submit this form.
Page 2:
[[!FormItRetriever]]
[[!FormIt?
&submitVar=`go`
&hooks=`spam,redirect`
&store=`1`
&redirectTo=`id-of-third-page`
]]
/* Page 2 quiz form goes here */
The FormItRetriever snippet will allow you to display your previously saved form data with placeholders relating to the names of your form fields => [!+fi.qzq1]]
To store the quiz form data on the database, you can use FormItSaveForm. This allows you to later view the data inside a Custom Manager Page (CMP) and export it, if need be.
Refer to the official docs for more usage examples: https://docs.modx.com/extras/revo/formit

Add a form with POST method on a SharePoint 2010 page?

The HTML I got asked to add to a page is:
<div>
<div> Click below to enter</div>
<form id="formID" method=POST action="http://www.someWebsite.com">
<input type="submit" name="do_login" value="Log in" />
<input type="hidden" name="username" value="someUsername" />
<input type="hidden" name="password" value="somePassword" />
</form>
</div>
I know I can't add a form like that because there is already on that SharePoint created, I had a look at http://www.sharepointboris.net/2008/09/making-post-and-get-forms-from-sharepoints-pages/ but when I follow the example and save SharePoint still strips out most of the code so how can I achieve what I want in another way?
Thanks in advance.
For our SharePoint 2007 installation, I created a quiz web part. Basically, it pulls questions and answers from a list, but the actual questions are presented and submitted using a form with POST variables. It's probably much more complex and in-depth than you're looking to go, but I made a custom web part to present the form, read the post variables, and execute associated functions. The big plus to using a custom web part is that you're able to put in nearly any content you want, since you're coding it in ASP.NET.
What I did was to create a custom .aspx page (not through the sharepoint gui) with the code I posted in my question, uploaded the page to a library and then linked to it via a page viewer web part
You can get the form to work as normal if you remove the tags and place the form control inside a div like so:
<div>
<div> Click below to enter</div>
<div id="formID" method=POST action="http://www.someWebsite.com">
<input type="submit" name="do_login" value="Log in" />
<input type="hidden" name="username" value="someUsername" />
<input type="hidden" name="password" value="somePassword" />
</div>
</div>
This way sharepoint will accept everything inside the div tags. In a asp.net when you create a page in sharepoint, the whole page is containied withing a form that why sharepoint does not allow you to use another form within it.
Hope this helps

Privacy prevent page from showing on back button

There will be a computer on display which users will write in their name, phone number, email and other information. We dont want users going back a page and grabbing ppls emails or other information.
How do i make it so when someone hits back the form no longer shows and a "sorry return to the first page" kind of thing. Theres a small chance there may be an agreement screen so hitting back and submitting another form and no seeing the screen may be trouble but i am not worried about that (or can say please put them on the same page).
I know its been asked but i havent seen any with this reason and the solutions i saw did not work (on firefox 3.6.10)
A little web searching found this page: Clear Web Forms After Submit
Basically calls the reset() function on all forms on the <body> tag's onload and unload events.
Code from the link:
<html>
<head>
<title>A Self-Clearing Form</title>
<script>
function clearForms()
{
var i;
for (i = 0; (i < document.forms.length); i++) {
document.forms[i].reset();
}
}
</script>
</head>
<body onLoad="clearForms()" onUnload="clearForms()">
<h1>A Self-Clearing Form</h1>
This form data will self-destruct when you leave the current web page.
<form method="post" action="page2.php" name="test">
<input name="field1"/> Field One
<p>
<input name="field2" type="radio" value="One"/>One
<input name="field2" type="radio" value="Two"/>Two
<input name="field2" type="radio" value="Three"/>Three
<input name="field2" type="radio" value="Four"/>Four
<p>
<input type="submit" value="Submit Form Data"/>
</form>
</body>
</html>
When the users enter information, save it and then send a redirect (through headers) to the page where users can enter their info.
Could have the form displayed as a result of a POST call, meaning the browser won't cache it. Then, if another user hits back, the browser will ask if they want to resend the request, but even if they do, you display them a blank page.

Resources