add parameters to form url before submit - html

I need to add a path to a file to the form url before submitting. I created therefore a text field and want to add the text to the url without php.
can somebody help?
the existing code:
<form action="http://127.0.0.1:8080/WebService1/HTTPMethod_1?new_value=value" method="post">
<input type="text" value="" size="30" name="filename">
<input type="submit" name="submit" value="Submit" class="continue-button">
</form>

look into using hidden input fields. these allow you to send form data, but not necessarily show a form field.
for instance:
<script type="text/javascript">
function setFormAction() {
document.myForm.action = document.getElementById("url").value;
}
</script>
<form name="myForm" method="POST" action="default.php">
<input type="value" name="url" id="url" />
<input type="submit" name="submit" onclick="setFormAction();" />
</form>

Related

create two form submissions from one button

I have a simple form that submits some data to an SMS server to send an SMS. I need to create two seperate messages from one button. message1 needs to go immediately and message2 needs a delay, which the gateway supports.
I Need two different "message" fields, one with the delay and one without. I dont think the server allows two commands from one submission. Is there a way of getting the forms to submit sequentially from one button ?
The fields that are common to both messages are :
<form action="https://api-mapper.clicksend.com/http/v2/send.php" method="post">
<input name="key" type="hidden" value="xxxxxxxxx" />
To: <input name="to" type="text" />
<input name="username" type="hidden" value="xxxxxx" />
<button type="submit" >SUBMIT</button>
the fields that cause me issues are:
<input name="message" value="message1" />
<input name="message" value="message2" name="schedule" value="time" />
try this.
<form id="form1" action="action.php", method="post">
<input name="key" type="hidden" value="xxxxxx"/>
<span>To:</span> <input name="to" type="text" />
<input name="username" type="hidden" value="xxxxxx" />
</form>
<form id="form2" action="action2.php", method="post">
<input name="message1" value="message1" />
<input name="message2" value="message2" name="schedule" value="time" />
</form>
<button type="submit" onclick="submitForms">SUBMIT</button>
<!-- add this tag after your body tag -->
<script>
var submitForms = function() {
document.getElementById("form1").submit();
document.getElementById("form2").submit();
}
</script>

pre-fill forms without id's

So, I was wondering if it was possible to pre-fill a form that doesn't include IDs. If I had a form like this:
<form action="" method="POST" >
<input type="text" name="title" />
<input type="submit" value="Submit" />
</form>
Would it be possible to pre-fill this form on an already built website, without editing the HTML code?
For reference, the link I would like to do this on is:
https://crystalmathlabs.com/tracker/compcreate.php
Since you asked for a jquery solution you can do this
var i=0;
$('form > input').each(function(){
$(this).attr('id','id'+i);
i++;
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<form action="" method="POST" >
<input type="text" name="title" />
<input type="submit" value="Submit" />
</form>

To where does a form in an IFRAME POST?

I got this form inside an iframe and want to know where the post actually goes. When I go to the network tab, it only shows the src of the iframe and not where the POST request was sent.
<iframe id="popupOverlay_iframe" name="popupOverlayWindow" src="/cgi-bin/admin/radio_contact.cgi?action=add&member_org_id=46757"></iframe>
The page inside this iframe contains the following:
<form name="add_member" method="post" onsubmit="return submitForm(this);" _lpchecked="1">
<label>
<input type="text" name="email.email" id="email.email" value="" class="init_focus" placeholder="Email:">
</label>
<input type="hidden" name="action" id="action" value="add">
<input type="hidden" name="step" id="step" value="email">
<input type="hidden" name="type" id="type" value="employee">
<input type="hidden" name="member_org_id" id="member_org_id" value="46757">
<input type="submit" name="submit" id="submit" value="Next">
<input type="hidden" name="redirect" id="redirect" value="https://stagemms.nationalmediacalls.com/cgi-bin/admin/radio_detail.cgi?action=show&id=46757">
</form>
On submit, the JavaScript function submitForm is called and its result is returned.
If submitForm and thus the snippet returns false, the form won't be submitted. (The JS might do it's own request.)
If submitForm and thus the snippet returns true, the form will be posted to the current page (/cgi-bin/admin/radio_contact.cgi?action=add&member_org_id=46757) because no action was specified.
In this situation, you should have seen something like this in your network tab:
(/foo.html is url of the outside page, and /foo.cgi?action=add&member_org_id=46757 is the url of the page in the iframe.)

Passing multiple values in JSP url

I am trying to pass multiple values in a JSP page url to another one.
The code is:
<form name="QuantityForm" onsubmit="return quantityValidation()" action='<%="basket.jsp?addItem="+product.PID%>' method="post">
Quantity <input type="text" name="quantity" size="5">
<input class="button button2" type="submit" value="Add to basket" />
</form>
How do i pass the value of quantity(the field of name="quantity") in the same URL? i know it's something like "Search.jsp?item=<%=search%>&item2=value2&item3=value3.." but i can't seem to structure it properly. Thanks
Do not put your ? and parameters in the action url. Put your parameters in input tags:
<form name="QuantityForm" onsubmit="return quantityValidation()" action='basket.jsp' method="post">
<input type="hidden" name="addItem" value="%product.PID%">
Quantity <input type="text" name="quantity" size="5">
<input class="button button2" type="submit" value="Add to basket" />
</form>
you're using method="post" which doesn't allow parameters to be passed into the url. change it to method="get" if you want the parameters to be passed along with the url.

Replace this by only one form

how can I replace this code, by only one Form please.
<form method="post" action="<c:url value="/deconnexion" />"><input type="submit" value="Déconnexion" class="deco" /></form>
<form method="post" action="<c:url value="/accueil" />"><input type="submit" value="Retour" class="deco" /></form>
What you want to do is impossible, each form will submit it's information to a single location, which is your action property in your form.
What you can do, alternatively, is manage two different cases in the same form. Your form would look like that :
<form method="post" action="<c:url value="/redirection" />">
<input id="deco" type="submit" value="Déconnexion" class="deco" />
<input id="retour" type="submit" value="Retour" class="deco" />
<input id="type" name="type" type="hidden" value="" />
</form>
You would need Javascript (Jquery) code to assign the type of redirection in the hidden field before the form is submitted :
<script type="text/javascript">
$('#deco').click(function(event)
{
$('#type').val("Déconnexion");
});
$('#retour').click(function(event)
{
$('#type').val("Retour");
});
</script>
Then, in the PHP, you would redirect to the page or function you wish with this condition :
if ($_POST["type"] == "Déconnexion")
// Do something
else if ($_POST["type"] == "Retour"
// Do something else