Input button action - html

If I have html forms like:
<form>
<div class="searchbox"><input type="text" name="searchbox" id="searchbox"></div>
<div class="searchbtn"><input name="search" type="button"></div>
</form>
how do I do that when you click on the button search begins without <input type="submit" /> button?

You need to write JavaScript code to submit a form.

Related

how can i add the input to the link in the action for a sech bar?

I am currently writing some script in HTML that creates a search bar. The page seems to redirect to https://schedule.nylas.com/?, but I want it to redirect to the input in the search box.
i.e the input in the search box is icecreamshop and it goes to https://schedule.nylas.com/icecreamshop
<form autocomplete="off" action="https://schedule.nylas.com" + input>
<div class="autocomplete" style="width:300px;">
<input id="myInput" type="text" name="" placeholder="store">
</div>
<input type="submit">
</form>
You can do this using javascript. If you just use the onclick attribute on the button then you don't even need to put it in a form. This just send the user to 'https://schedule.nylas.com/' + (input with id="myInput") when they click on the button.
<input id="myInput" placeholder="Search">
<button onclick="window.location.href='https://schedule.nylas.com/'+document.getElementById('myInput').value;">Search</button>

Nuxt.js: <input type="search"> does not work

If you write <input type="search"> in HTML5, the keyboard of the input in safari on iOS is as follows.
Submit button is "search".
By the way, I am trying to create a search form in Nuxt.js as well and mark it up in component as below.
<div class="search-form">
<form
#submit.prevent
#keyup="onKey($event)">
<input
v-model="keyword"
:placeholder="search form"
type="search"
#keypress="setCanMessageSubmit($event)">
</form>
</div>
However, the keyboard shows "return" instead of "search" as shown below.
Why is this?
Is there a way to solve it?
Try adding action attribute to your form tag.
<div class="search-form">
<form
action="."
#submit.prevent
#keyup="onKey($event)">
<input
v-model="keyword"
:placeholder="search form"
type="search"
#keypress="setCanMessageSubmit($event)">
</form>
</div>
My fiddle: https://jsfiddle.net/pompopo/2b0yc6oq/7/

HTML tag form without "action" attribute

I'm using this HTML code in an HTML page:
<form method="post">
<div class="form-group">
<input type="text" class="form-control" name="username">
</div>
<div class="form-group">
<input type="password" class="form-control" name="password">
</div>
<input type="hidden" name="ref" value="post-ad.php"/>
<button type="submit" name="submit" id="submit" class="btn">S'identifier</button>
</form>
On clicking submit button which action will this form execute? I noticed that it execute the value of input named "ref" in this example "post-ad.php" or "index.php" or "dashboard.php". Is it normal?! As I know the action attribute is mandatory?
without action attribute it will POST/GET to the same page
see here
If I understood right you're asking about action attribute that goes inside <form>.
If you put nothing there, it'll send the POST to the same page it is right now. If that form is in "index.php" it'll send all <form> data to "index.php"
You call form without action with this code:
<form action="javascript:void(0);"></form>

How to submit a form after submitting other form?

I'm working with html and jsp, and I'm trying to do a custom search that performs the same action as that of a catalog search that is on another page. I have two pages:
There is a page (outside my app, so I can't modify at all) that is a catalog search:
<form name="formulario" id="formulario" method="post" action="Main">
<input tabindex="116" size="55" id="txtSimpleSearch" name="txtSimpleSearch">
<input value="Search" type="submit" name="btnSearch" tabindex="102">
</form>
I have to create a page in my app that works as a custom search in that catalog seach. So I created this form:
<form method="post" rel="external" action="http://example.com/pages/SimpleSearch" target="_blank">
<fieldset>
<label for="txt"><span class="label">Text:</span>
<input name="txtSimpleSearch" id="txt" type="text"></label>
</fieldset>
<div>
<input class="boton" value="Search" type="submit">
</div>
</form>
The action of the second form (my page) goes to the catalog search, with the value of txt input, but it isn't do the search on the first page (the catalog search page not execute the submit of the form formulario).
Maybe I could get the form of the catalog search page and do the submit using Javascript? Or isn't possible?
Thanks.
You'll have to use the same name attributes for your input, so the page will be able to get the search value.
<form method="post" rel="external" action="http://example.com/pages/SimpleSearch" target="_blank">
<fieldset>
<label for="txt"><span class="label">Text:</span>
<input name="txtSimpleSearch" id="txt" type="text"></label>
</fieldset>
<div>
<input class="boton" value="Search" type="submit" name="btnSearch">
</div>
</form>
change input type='submit' to type='button' , add attribute to the input onclick='actionSubmitForm1()' then use javascript submit
document.forms["myform"].submit();
then submit you'rs second form
document.forms["myform2"].submit();

IE9 is auto-submiting form when <a> links clicked

While using IE9, every link (when clicked) the search form is being submitted. Every link seems as if it is redirecting to the action value of the search form.
There is no java script attached to the form element.
<form action="/my-search-url" method="post">
<input type="submit" value="search" />
<input type="text" value="" />
</form>
The issue was with the order of the form elements. Apparently the original developer decided to place the submit button before any input elements. By putting the submit input last (or removing it) fixed this issue.
<form action="/my-search-url" method="post">
<input type="text" value="" />
<input type="submit" value="search" />
</form>