How can I split the django-haystack search form and the results - django-haystack

I want to have the search form of django-haystack on the base.html template of my blog but the results on a different template page how can I do that ?

Structure the form to submit the data to the correct URL,
<form action="/search/?q=">
<input type="text" name="q" id="id_q">
<button type="submit">Go</button>
</form>
So that code would live on the base.html page, and than submissions to it would post to the default '/search' page, the full search bar/options and results. I have this code in use on a pinax site with the default haystack install and it works.

Related

how to access form input elements in get request for node

In my html in a node application I have a form as follows:
<form action="/getRoute" method="get">
<input type="hidden" name='a' value=<%- array1[0].element1 %>>
<input type="hidden" name='b' value=<%- array2[0].element2 %>>
<button type="submit">Submit</button>
</form>
When I click submit, the getRoute route is executed successfully (confirmed by console.log statement) - however, I cannot access the values of the hidden input fields by req.body - would anyone know how I can access these, or alternatively use another html element to pass data into the route?
Just found out that you these inputs are passed via the URL and can be accessed by req.query.a and req.query.b - it's not ideal to send sensitive data via get requests since the URL can be seen.

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

Netlify form submissions are blank

When I submit my Netlify form the server responds with a 200 status and I get the 'thank you' response page. However, when I check the form submission in the Netlify admin, they are all blank. I've inspected my xhr requests and the data shows in the 'params' section of the browser dev tools.
Disclaimer: I work for Netlify.
When our service stores blank submissions, it has not received any fields from the submission which were defined in the html version of the form with the same name parameter in its definition as the submission.
To start off with, it's useful to know that our service requires a plain html version of your form, with a name parameter as well as the netlify or data-netlify=true parameter; this is what prepares your site to accept form submissions at all, so you had that set up right already; if you didn't, you'd get a 404 when POSTing.
Once you have this in a deploy and we parse it correctly, you'll see the form name in your site settings dashboard on the 'Forms' tab. Note that we ALSO pull all the field names we'll save and show to you in notifications or the dashboard from this file and only this file, so make sure you give each form field all a name as well, in that html file.
If you see the form in your dashboard, yet get a blank submission when you are sure data was POSTed, this probably has one of three causes:
Netlify did not correctly process your field names from the html version of your form. The service will only properly handle the fields which we see in that html version at deploy time.
Netlify does matching by field name at submission time, so make sure that what your site sends to us then matches up between with your deployed html copy of the form. This happens automatically for pure html (no JS) forms since you are POSTing from the file which is the canonical "definition" of your form fields; however for javascript forms you need to take care that the names match up. Put another way, you cannot later add new fields dynamically in javascript and send them (Netlify will accept all fields, as you have seen; but will not store them or notify you about ones that were not processed at deploy time!)
One more quirk that could get in the way: having multiple copies of a form with the same name in your deploy. Only one will be processed, so if you happen to have an errant <form name=test netlify></form> in another html file (or even the same one!) - it could be the one that we process rather than the other form also named test. So, make sure that you only send a single html definition of your form. Note that some frameworks like gatsby render your jsx down into html before deploy, meaning that if you have a plain html file form definition in your deploy - it could be processed instead of the copy gatsby built.
This blog post describes a successful form built in a react app: https://www.netlify.com/blog/2017/07/20/how-to-integrate-netlifys-form-handling-in-a-react-app/
I missed the "name" attribute in input field.
Every input in the form must have a "name" attribute. Something like <input name="email" ...> or <textarea name="message" ...> is what you need.
Don't miss the "name" attribute for both parent and child layers
<form name="contact" method="POST" data-netlify="true">
<input type="text" placeholder="name" class="box" name="name">
<input type="email" placeholder="email" class="box" name="email">
<input type="text" placeholder="project" class="box" name="project">
<textarea name="message" id="" cols="30" rows="10" class="box message" placeholder="message"></textarea>
<div class="field">
<div data-netlify-recaptcha="true"></div>
</div>
<button type="submit" class="btn"> send <i class="fas fa-paper-plane"></i> </button>
</form>

How can I submit a form to a new tab in my 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>

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

Resources