I don't know how to put it exactly, so here goes.
I've created a search bar on my webpage that uses your input text to search another website.
This is what I've got (things have been censored):
<form name="search" class="form-search" method="get" action="http://www.nameofwebsite.com/search.php?">
<input name="searchbynum" type="text" class="search-query input-large" onkeypress="return submitenter(this,event)">
<button type="submit" class="btn btn-primary">Search</button>
</form>
When searching on the actual website, the search URL looks like this:
http://www.nameofwebsite.com/search.php?searchbynum=search+phrase&searchbydesc=&Submit=Go
Where "search+phrase" is what is searched. To get to the point,
What would I have to do to add the "&searchbydesc=&Submit=Go" at the end of the search?
Add hidden fields to your page.
<form ...>
<div>
<input type="hidden" name="searchbydesc" value="" />
<input type="hidden" name="Submit" value="Go" />
</div>
</form>
Note that your HTML as it is, is invalid. A <form> element cannot have <input /> elements as immediate children, they must be wrapped in a <div> or <fieldset> or other similar elements.
Related
Im trying to implement the "i'm feeling lucky" functionality in a quite simple web. The thing is that at first, without this button, the query was properly done (i mean when doing a normal search). But, when i included the im feeling lucky button, the normal search stopped working and know even when you click on norma search it goes directly to the firs result. im new to HTML and still lost regarding forms. Note that i cant do it using js cause its for an assignment meant to be done only with HTML.
Thanks a lot for your help :D
Image
Advanced
<form action="https://www.google.com/search?">
<div><input type="text" name="q" id="search"></div>
<div>
<input type="submit" value="Google Search" id="button">
<form>
<input type="hidden" name="btnI" value="1">
<input type="submit" value="I'm feeling lucky" id="button">
</form>
</div>
</form>
In case that you need two buttons with one text field, perhaps a different approach would be useful. Use
<button type="submit" name="action" value="val1"></button>
and
<button type="submit" name="action" value="val2"></button>
but be careful with this one, since some browsers will upload value from the "value" attribute.
The other method is to use some PHP in your script, like this:
<input type="submit" name="update_button" value="Update" />
<input type="submit" name="delete_button" value="Delete" />
<?php
if (isset($_POST['update_button'])) {
//update button
} else if (isset($_POST['delete_button'])) {
//delete button
} else {
//no button was pressed
}
?>
Happy coding!
You cannot nest forms
You need two forms:
Image
Advanced
<form action="https://www.google.com/search?">
<div><input type="text" name="q" id="search"></div>
<div>
<input type="submit" value="Google Search" id="button">
<input type="hidden" name="btnI" value="1">
</div>
</form>
<form action="https://www.google.com/search?"><input type="hidden" name="q" value="I'm feeling lucky"><button>I'm feeling lucky</button></form>
A few notes:
you have a form tag nested inside the other which is wrong.
you have two submit button with same id.
Remove these issues and it will work as desired.
As I see it, you want to have window inside another window, both of which will have buttons? In that case, don't go form inside form, make it div inside div and in both of them, enter a form, here's and example:
<div id="div1">
<form action="https://www.google.com/search?">
<input type="text" name="q" id="search">
<input type="submit" value="Google Search" id="btn1" class="button">
</form>
<div id="div2">
<form action="https://www.google.com/search?">
<input type="text" name="q2" id="search">
<input type="submit" value="Google Search" id="btn2" class="button">
</form>
</div>
</div>
I am trying to mirror the google image search.
so far I know that q is the name for the actual google search (or query).
On the address it will look: www.google.com/search?q=parrot
but on the google image search also appears /search?q=parrot&tbm=ish
I looked and found out that tbm stands for "to be match" and is a filter and I guess is the filter to match the images... but I don't have a clue how to put inside my html code.
So far I have done this:
<form action="https://www.google.com/search" class="form">
<input type="text" name="q" class="search_bar"
<input type="submit" value="Search" class="submit">
</form>
How do I add the tbm filter? Thanks!
You can add a hidden input field and set the value of it.
example
<form action="https://www.google.com/search" class="form">
<input type="text" name="q" class="search_bar">
<input type="hidden" name="tbm" value="ish">
<input type="submit" value="Search" class="submit">
</form>
Trying to make Google Image Search Clone using HTML form where after entering text in the search field it will take you directly to Google Image search results page.
Here is the code that I am using:
<body>
<form action="https://google.com/search">
<input type="text" name="q">
<input type="submit" value="Google Search">
</form>
</body>
It will take to normal google search, how do I change it to google image search result page?
You have to change the action, as such:
<form method="get" action="http://images.google.com/images">
<input type="text" name="q" />
<input type="submit" value="Google Search" />
</form>
Google image search link is of the following format
https://www.google.com/search?q=```query```&tbm=isch
Each of the parameters, q and tbm, requires an input tag but tbm does not require any user input.
'GET_parameter_name=value' for every input tag before submit button is appended by '&'.
<form action="https://www.google.com/search">
<input type="text" name="q" id="box">
<input type="hidden" name="tbm" value="isch">
<input type="submit" value="Image Search" >
</form>
Source:
https://stenevang.wordpress.com/2013/02/22/google-advanced-power-search-url-request-parameters/
https://www.xul.fr/javascript/parameters.php
I need to pass this so a hardware engineer can do his work but it's not working. Any suggestions?
http://wfbscd13.cadence.com/cgi-bin/motd.cgi?msg=3&cmd=replace&text="
Here is my code...
<div class="messageform">
<fieldset>
<legend>Title 1</legend>
<form action=http://wfbscd13.cadence.com/cgi-bin/motd.cgi?msg=1&cmd=replace&text=" method="post">
<label for="mestext1"></label>
<input type="text" size="100" maxlength="80">
<div class="floatright">Titles can be up to 80 Characters... upload file if beyond 80 chars  <input type="submit" name="button1" id="button1" value="Replace"></div><br>
I thought I was good on this code but it's not working right, any ideas? Did I miss something?
Better like this:
<div class="messageform">
<fieldset>
<legend>Title 1</legend>
<form action="http://wfbscd13.cadence.com/cgi-bin/motd.cgi" method="GET">
<input type="hidden" name="msg" value="1">
<input type="hidden" name="cmd" value="replace">
<label for="mestext1"></label>
<input type="text" id="mestext1"" name="text" size="100" maxlength="80">
<div class="floatright">Titles can be up to 80 Characters... upload file if beyond 80 chars
<input type="submit" name="button1" id="button1" value="Replace">
</div>
</form>
</fieldset>
</div>
You need to be more careful with closing quotes and tags.
If a URL has a '?' in it, it probably means they want it as a GET not a POST.
Use hidden variables for the fixed params.
Don't repeat the text param.
The for of a <label> needs to point to the id of a tag.
If this is your entire code, then its not working probably because the code is not well-formed , i.e. there are places where you have missed to close the tags.
Using <form method="get"> element including <input type="submit"> element, we can have a way to GET a web page with some fields specified by the <input type="text" name="studentId"> elements, but can I customize those fields?
For example: I always want to add a action=true to the GET url to let the URL be something like this: http://example.com/?studentId=123&action=true?
Use <input type="hidden" name="action" value="true" />
inside your form.
You can add a hidden form field, though the name action is not a good one, as form has an action attribute and this name can conflict when scripting the form:
<input type="hidden" id="something" name="something" value="somthingelse" />
<div id="gbqffd">
<input type="hidden" value="en" name="h1">
<input type="hidden" value="d" name="tbo">
<input type="hidden" value="search" name="output">
<input type="hidden" value="psy-ab" name="sclient">
</div>
Google always has the answer; in this case I never had to do a search just look at the source :)