form action parameter not working - html

Test
<br><br>
<form action="index.php?page=test">
<input type="text" placeholder="enter text"> </input>
<button type="submit">Send</button>
</form>
Why is the link working correctly while the form gets me the url http://example.com/index.php? in the adress bar of the browser?
Every parameter i define in the action attribute is getting cut off

you have to use this code.
Test
<br><br>
<form action="index.php" method="get">
<input type="text" placeholder="enter text"> </input>
<input type="hidden" name="page" value="test">
<button type="submit">Send</button>
</form>

You are submitting a GET form. The data in the form will be expressed as a query string and replace the one in the URL in the action.
Move the data from the query string into hidden inputs inside the form.

Related

How do I add a query to a get request with HTML?

I have made this:
<form action="links.php" method="get">
<input type="text" name="link" value="" style="height:25px;length:0px;font-size:8pt;"><br>
Direct: <input type="submit"><br>
Show: <input type="submit">
</form>
Is there any way I can pass a parameter when I press a different button? When I click now it sends me to links.php?link= which is good, but I want to do so that if I click one of the buttons, it sends me to links.php?link=&up=no.
I think I found a solution but it uses javascript, I want to do it with HTML only.
If you're looking to add a parameter based on what submit button was pressed, you can add a name to each of them:
<form action="links.php" method="get">
<input type="text" name="link" value="" style="height:25px;length:0px;font-size:8pt;"><br>
Direct: <input type="submit" name="direct"><br>
Show: <input type="submit" name="show">
</form>
Pressing the direct submit button will give:
?link=&direct=...
Pressing the show button will give:
?link=&show=...
edit
In the event that you want to pass a specific value for each button (which isn't tied to it's text like a submit input is), use the button tag instead of the input tag and pass it explicitly:
<form action="links.php" method="get">
<input type="text" name="link" value="" style="height:25px;length:0px;font-size:8pt;"><br>
Direct: <button name="direct" value="foo">Submit</button><br>
Show: <button name="name" value="bar">Submit</button>
</form>
which would result in: ?link=&direct=foo and ?link=&show=bar

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();

How to set button's label without changing value in post

I've got this code in html:
<form action="/login/" method="post">
<input type="text" name="login">
<input type="text" name="pass">
<input type="submit" value="login" name="type" >
<input type="submit" value="register" name="type" >
</form>
When I submit this form it sends a get request with the value of the field of the button clicked. However I want to change the label of the button without changing the value sent in get. Is it possible or not?
Use a button element:
<button type="submit" name="type" value="register">Sign up for an account</button>
Note that old IE has problems with this.

Two submit buttons

I have two forms on a same page and I have two submit buttons...so how do I check if the user filled out the first form before clicking the submit button on second form? The first form posts the data to php page which presents on a same page as the html and the second form sends the data to another PHP page with thank you message....I mean how do force the user to finish the first form before clicking the submit button on the second form? if the user hits the submit button on the second form, the form directs to thank you page with out checking if the user finished the first form..how do I stop that?
<html>
<body>
<form action="" method="post" enctype="multipart/form-data">
<input type="hidden" name="submited" value="true" />
<label for="file">Choose Photo:</label>
<input type="file" name="file" onchange="file_selected = true;" required>
<input type="submit" value="Submit" name="submit">
</form>
<form action="Send.php" method="post">
First Name:<input type="text" name="fname" required><br>
Last Name:<input type="text" name="lname" required><br>
Choose Username:<input type="text" name="username" required><br>
Age:<input type="text" name="age" required><br>
<input type="submit" value="Submit" name="submit">
</form>
You can change the name field and then access the value on the server side.
For example:
<input type="submit" value="Submit" name="submitOne" />
If you're using php you could use something like this:
if(isset($_POST['submitOne'])){ /* first one pressed */ }
There are also some other options like using jQuery or javascript to validate first.
Try: http://bassistance.de/jquery-plugins/jquery-plugin-validation/

pass form input value to action

I have a page (module-access.php).
On the page I have a form with one text input field. I'd like to set whatever is typed in this field to be part of the form's action.
<form action="module-access.php?company=THE-USERS-INPUT" method="post" name="company" id="company">
Company Name: <input type="text" name="textfield" id="textfield">
<INPUT TYPE="submit" name="submit" VALUE="Go"></FORM>
Thanks
Just change the input name from textfield to company and the action type to GET
<form id="myform" action="module-access.php" method="GET">
Company Name: <input type="text" name="company" id="company">
<input type="submit" name="submit" value="Go">
</form>
Why? Does it matter whether it's passed in the POST or GET? You can always just use REQUEST.
If it does matter then you'll need to use JavaScript to modify the action before you POST the form. Not very hard to do.