Passing multiple values in JSP url - html

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.

Related

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.)

Go to a link by using it's parameters?

I have a url and the button doesn't work right so i'm having to input the values into the url. I know it's possible to take the values and put them into the url to get to the page. How is this done? For example
<form method="get" action="https://example.url.com/courses/enrol/manual/manage.php" id="enrolusersbutton-1">
<div>
<input type="submit" value="Enroll users">
<input type="hidden" name="enrolid" value="276">
<input type="hidden" name="id" value="92">
</div>
</form>

post not send form data

I have a problem with sending posts in codeigniter, reading other posts I set the variable max_input_vars = 1000. but does not send the data.
the resulting in html is:
<form id="0" action="CO_controller" method="post">
<input id="idric_0" value="0.02508800 154401490122">
<input id="name_0" value="val0">
<input id="per_0" value="10">
<input id="unit_0" value="g">
<input id="ric_0" value="0.02508800 1544014901">
<input id="command0">
<input id="mod0" type="submit" value="Modific" onclick="document.getElementById('command0').value = 'modific';">
<input id="eli0" type="submit" value="Deleta" onclick="document.getElementById('command0').value = 'deleta';">
<input id="id_sal0" value="0.02508800 1544014901">
</form>
<form id="1" action="CO_controller" method="post">
<input id="idric_1" value="0.02508800 154401490122">
<input id="name_1" value="val0">
<input id="per_1" value="10">
<input id="unit_1" value="g">
<input id="ric_1" value="0.02508800 1544014901">
<input id="command1">
<input id="mod1" type="submit" value="Modific" onclick="document.getElementById('command1').value = 'modific';">
<input id="eli1" type="submit" value="Deleta" onclick="document.getElementById('command1').value = 'deleta';">
<input id="id_sal1" value="0.02508800 1544014901">
</form>
the operation is correct ie when I click the button, set the value of the command and submit.
in debug, I go to see the variable $ _POST and it is empty
As said in the comment, you should use name instead of id. By using id you are not passing the values correctly.
Unless you have a route defined so that CO_controller points to a method (and not just a controller) this is not going to work:
<form id="0" action="CO_controller" method="post">
Your form action should point directly to the method within the CO_controller controller which will process the form input.
Assuming the method within the controller is called process_form your form should point to:
<form id="0" action="CO_controller/process_form" method="post">
give it a go and let us know how it works

send get parameters using action attribute of form and even send the form elements

I want to sent parameters using action and even the value of input name=edit parameters but only
ajaxify/modify.php?edit=something
is sent instead of
ajaxify/modify.php?f=update&id=5&edit=something
Is there any solution for this or I am doing some blunder. Please help me.
<form id="update" action="ajaxify/modify.php?f=update&id=5">
<input type="text" name="edit" value="something"/>
<input type="submit" value="update"/>
</form>
Use hidden input. This will work for get/post methods. Example:
<form id="update" action="ajaxify/modify.php">
<input type="hidden" name="id" value="5"/>
<input type="hidden" name="f" value="update"/>
<input type="text" name="edit" value="something"/>
<input type="submit" value="update"/>
</form>
Set the method attribute of the form element to get to make it do a get instead of a post.
<form id="update" action="ajaxify/modify.php?f=update&id=5" method="get">

Passing parameter and user input

I am trying to pass a few parameter and a user input to a search_form.asp page.
<form action="search_form.asp" method="Post">
<input type="text"name="fname"/></th>
<input type="submit" value="Update">
</form>
And on search_form.asp...
lname=request.QueryString("Lname")
fname=request.form("fname")
But I am unable to see lname when i place Response.Write("<p>Name: " & lname) in search_form.asp
The query string is not preserved when you submit the form, so search_form.asp will not have a query string. As an alternative, could you include the query string as a hidden field:
<form action="search_form.asp" method="Post">
<input type="text"name="fname"/></th>
<input type="submit" value="Update">
<input type="hidden" name="lname" value="<%=Request.QueryString("lname")%>" />
</form>
And then refer to Request.Form("lname") in search_form.asp.
Alternatively, could you include the query string in the form action?
<form action="search_form.asp?<%=Request.ServerVariables("QUERY_STRING")%>" method="Post">
<input type="text"name="fname"/></th>
<input type="submit" value="Update">
<input type="hidden" name="lname" value="<%=Request.QueryString("lname")%>" />
</form>
This should pass the query string on the original page when the form is submitted.