I am trying to figure out, how can I automatically submit a url at the following page
http://www.facebook.com/sharer.php
without actually clicking on the submit button.
Thanks.
You can find that from the page source. There is a form defined...
<form action="/sharer.php" method="get">
and the button is a submit button, which means that when you click the button, the form data is sent as a get request to http://www.facebook.com/sharer.php - in other words, it submits back to itself.
Update - asker wants to know how to submit the form without clicking on the link.
The form is:
<form action="/sharer.php" method="get">
<input type="text" class="inputtext DOMControl_placeholder" id="share_input" name="u" placeholder="http://" value="http://" title="http://" />
<input type="hidden" name="appid" value="2309869772" />
<label class="mrm uiButtonNoText uiButton uiButtonConfirm uiButtonMedium" id="share_submit">
<input value="Share" type="submit" />
</label>
</form>
So you need to GET a URL with form data something like the following
http://www.facebook.com/sharer.php?u=your_encoded_url&appid=yourappid
Related
I want to create a form about the job application page, but i want to do some validation about if the user already fill up all the element in the form, only the submit button can click, and the submit button will link to another html page to show "your application is successful received". How can i do, thank you so much. I so a part of my code
<label for="Minimum Salary (MYR)"><img src="Web Page Image (Koh Xin Hao)/Money.png"/> Minimum Salary (MYR)</label>
<input type="text" id="Minimum Salary (MYR)" name="Minimum Salary (MYR)" value="RM " maxlength="8" required="required">
<label for="Nationality"><img src="Web Page Image (Koh Xin Hao)/Card Issuing Country.png"> Nationality</label>
<input type="text" id="Nationality" name="Nationality" placeholder="Malaysia" required="required">
<div><p>The application process will take up to 2 days. If your application is approved by the company, we will inform you via email or telephone call. Thanks for you application ^-^</p></div>
<input type="submit" required="required" class="btn" onclick="location.href='Payment Successful.html'"/>
<button type="submit" class="btn" onclick="location.href='Payment Successful.html'">Submit</button>
Seen the form is not fill up anything but the submit button also can click. I already put required="required" inside my code but the validation is not working.
If i m not wrong so you want to ask that how to validate all fields and submit form to a new page.
If yes so
<input type="?" name="?" required />
add required attribute to require that feild
And give a action attribute to your form where u want to submit that form
Example <form action="your page" type="post">
Hope it helps you
Let me know if i misjudge your problem
You need to use Javascript to check if the fields have been filled in and if so disable the button.
You also need to change the required="required" to just required as shown here https://www.w3schools.com/tags/att_input_required.asp
You also need to wrap it all in a form tag and use the action field to supply the next page when it is submitted as per https://www.w3schools.com/tags/tag_form.asp
You may need to do more with validation in Javascript this is basicly only disabling the other button if the fields aren't blank. You can see more about JS validation here https://www.w3schools.com/js/js_validation.asp
function validateForm(){
var input1 = document.getElementById("input1").value;
var input2 = document.getElementById("input2").value;
if(input1==""){
console.log("input1 is blank!");
}else if(input2==""){
console.log("input2 is blank!");
}else{
console.log("inputs are not blank");
document.getElementById("button").disabled = true;
}
}
<form action="form_submitted_page" method="POST">
<label for="input1">input1</label>
<input type="text" id="input1" name="input1" required onchange="validateForm()">
<label for="input2">input2</label>
<input type="text" id="input2" name="input2" required onchange="validateForm()">
<input type="submit" value="Submit">
</form>
<button id="button" onclick="document.location.href='google.com'">Google (to be disabled)</button>
I have an html form that submits a post request.
<form asp-controller="Home" asp-action="Check" method="post">
<textarea id="uname" name="uname">myName</textarea>
<input type="submit" name="req" value="finish" />
<input type="submit" name="req" value="begin" />
</form>
When it submits a request using e.g. the word "myName" in the text box and the "finish" button it will send the following post request body:
uname=myName&req=finish
What I don't understand is how post requests are assembled when I push the button - how can I add more values to the request? are these all automatic? can I attach more attributes within button tags e.g. personalid="123" and send these in the request also? I'm aiming so that when I click the finish button I can send the req=finish as well as personalID=123 but I'm not sure if this is possible just by putting in more attributes.
If the personalID is meant to be constant you could put it in a hidden field:
<input type="hidden" name="personalID" value="123"/>
If users are meant to be able to edit the id you could use a textbox:
<input type="text" name="personalID" value="123"/>
I want a html button with parameter functionality.
new/?sorting=desc is the url that it should link to. But when I try, the parameter is not passed. How should it be done? I tried both the methods below but none worked.
<FORM METHOD="GET" ACTION="./?sorting=desc">
<INPUT TYPE="submit" VALUE="Äldst först">
</FORM>
I want buttons that behave like these links:
Äldst först
Nyast först
If you want something to act as a link, then you should use a link.
That said:
When you submit a GET form, the query string is removed from the action and a new one is generated from the data in the form.
You need to store the data in hidden inputs.
<form action="/social/tracking/new/">
<input type="hidden"
name="sorting"
value="desc">
<input type="submit"
value="Nyast först">
</form>
<form action="/social/tracking/new/">
<input type="hidden"
name="sorting"
value="asc">
<input type="submit"
value="Sort the other way">
</form>
If you are using jQuery, you can use the code below.
This will fill a hidden input with the correct value when you click on one of the submit buttons.
<form method="get" action="./">
<input type="hidden" name="sorting" id="sorting" value="" />
<input type="submit" value="Äldst först" id="sort_desc" />
<input type="submit" value="Nyast först" id="sort_asc" />
</form>
<script>
$('#sort_desc').click(function(){
$('#sorting').val('desc');
});
$('#sort_asc').click(function(){
$('#sorting').val('asc');
});
</script>
I think its not possible. A form is used to send data (mostly) via POST or GET. Your goal is to open a specific URL. I would create a standard and would style it like a button. Whats the reason you want to use a button?
here is my code
<body>
<input type=text name=name>
<form action=new3.jsp method=post name="f1">
<input type=text name=name>
<input type=submit value=next>
</form>
<form action=new1.jsp method=post>
<input type=submit value=back>
</form>
</body>
as you can see there are two forms here with two different submit buttons named "next" and "back". The text box is in the form where "next" button is. My question is here how to send the value of this text box to "new1.jsp" clicking "back button" without using javascript. Thanks in advance...
Don't post form to JSPs. Post the to servlets instead, and let the server analyze the parameters and forward to the appropriate JSP depending on which button has been clicked:
<form action="/controllerServlet" method="post" name="f1">
<input type="text" name="name"/>
<input type="submit" name="destination" value="next"/>
<input type="submit" name="destination" value="back"/>
</form>
Using the above form (which BTW, is valid HTML), the servlet can use the value of the "destination" parameter. If it's "next", it should forward to new3.jsp. If it's back, it should forward to "new1.jsp". And if, for example, you want to redisplay the same page because the user didn't enter a valid value in the text field, it can do so.
That's the well-known MVC pattern. You should use it.
I have two JSP pages A and B and also a Servlet.
The flow is like this:
User fill in some information in page A
Then the user fill in some other information in page B
After the user finishes B, he/she will click a button and submit all data (from both A and B) to the Servlet.
How should I design this?
My plan is
In A's next button, it is actually a <a> tag with link to the href of B. All information from A should be passed to B via that link. I don't know how to do this step.
In B's finish button, it is a form input submit button. I don't know whether I can or how I add A's data into this form.
Anyone can help me out?
Thanks
In your A.jsp create a link, for e.g.: Go to B
Pass your parameters from URL.
In B.jsp use expression language to get parameters values:
<form action="FinalServlet" method="post">
<input type="text" name="p" value="your value"/>
<input type="hidden" name="p1" value="${param.param1}"/>
<input type="hidden" name="p2" value="${param.param2}"/>
.......
<input type="submit" value="Finish"/>
</form>
Hope this helps.
EDIT:
If you want to use a form with input fields in A.jsp:
<form action="B.jsp" method="post">
<input type="text" name="param1" value="value1"/>
<input type="text" name="param2" value="value2"/>
.......
<input type="submit" value="Finish"/>
</form>
You will receive parameters in B.jsp using the same EL.