There is a form:
<form id="1" action="file.php" method="POST">
<textarea type="text" name="stream" style="width:80%;" rows="7" cols="40"></textarea>
<br /><br /><br />
<br /><br />
<label for="number"><span style="font-size: 30pt;">number of results:</span></label>
<input type="text" name="number" style="width:70px; margin: 50pt; ">
<br />
<br /><br /><br />
<input type="submit" value="Submit form">
</form>
A user is supposed to enter value of both form elements: stream, number
My objective is to automate the process by setting e.g. stream="test" and number="5" and then open file.php.
How can I accomplish that?
CodePudding user response:
I think this might be the result you want. You just add the "Attribute value"
<textarea type="text" name="stream" style="width:80%;" rows="7" cols="40">test</textarea>
<input type="text" name="number" value="5" style="width:70px; margin: 50pt;">
or
<input type="number" name="number" value="5" style="width:70px; margin: 50pt;">
CodePudding user response:
You mean like this? You will need to use JS to submit
Set values on server
window.addEventListener("DOMContentLoaded", () => {
document.getElementById("form1").submit();
})
<form id="form1" action="file.php" method="POST">
<textarea type="text" name="stream" style="width:80%;" rows="7" cols="40">test</textarea>
<br />
<label for="number"><span style="font-size: 30pt;">number of results:</span></label>
<input type="text" name="number" style="width:70px; margin: 50pt;" value="5">
<br />
<input type="submit" value="Submit form">
</form>
or set values on client
window.addEventListener("DOMContentLoaded", () => {
document.querySelector("[name=stream]").value="test";
document.querySelector("[name=number]").value="5";
document.getElementById("form1").submit();
})
<form id="form1" action="file.php" method="POST">
<textarea type="text" name="stream" style="width:80%;" rows="7" cols="40"></textarea>
<br />
<label for="number"><span style="font-size: 30pt;">number of results:</span></label>
<input type="text" name="number" style="width:70px; margin: 50pt; ">
<br />
<input type="submit" value="Submit form">
</form>