I have a form like this:
<form rel="search" action="/archives">
<input name="keyword" type="text" value="search..." />
<input type="submit" value=submit" name="submit" />
</form>
When a User click on submit...I want sent parameters by URL...
exact this URL: http://examole.com/archives/keyword
Or any alternative way...
.
Is it possible?
Edit
I try change above code to this:
<form rel="search" action="/archives" method="get">
<input name="keyword" type="text" value="search..." />
<input type="submit" value="submit" />
</form>
The result:
http://127.0.0.1/archives?keyword=search...
How can I change The URL to this:
http://127.0.0.1/archives/search...
Yes, you can. Just use method="get"
<form method="get" rel="search" action="/archives">
<input name="keyword" type="text" value="search..." />
<input type="submit" value=submit" name="submit" />
</form>
Related
All this html on same page:
<form name="name1" ....>
<input name="tName"type="text">
<input value="Search" type="submit">
</form>
<form name="name2"....>
<input name="tName" type="text">
<input value="Search" type="submit">
</form>
doc = Jsoup.connect("addr")
.data("tName", "foo")
.userAgent("Mozilla")
.post();
Now, how do I know which form I submited ? Where to specify to which of 2 forms inputed data belogs to, in jsoup code ?
<form name="name1" ....>
<input name="tName"type="text">
<input value="Search" type="submit">
<input name="formNumber" value="form1" type="hidden">
</form>
<form name="name2"....>
<input name="tName" type="text">
<input value="Search" type="submit">
<input name="formNumber" value="form2" type="hidden">
</form>
doc = Jsoup.connect("addr")
.data("tName", "foo")
.userAgent("Mozilla")
.post();
If you can't get the name of the form itself, you'll be able to get the values of the hidden inputs.
JSFiddle: https://jsfiddle.net/apamvz1r/1/
I have the following code that I would like to eliminate the need for the visitor to click the radio button before searching... Is this possible? I would like to completely eliminate this field or hide it.
<input type="radio" name="RProducts" onclick="frmSearch.Products.value='BB'">
If you don't click on the radio input, it doesn't work properly, even if i pre-select it, it still needs to be directly clicked on. Is there a way around this?
<form action="http://search1.bestbenefits.com/provsearch.asp" method="post" name="frmSearch" id="frmSearch" target="_blank" onSubmit="return CheckParams()">
<input type="hidden" name="Products" value="">
<input type="hidden" name="Title" value="24-7_MedPlan-20140416">
<input type="radio" name="RProducts" onclick="frmSearch.Products.value='BB'">Search Providers
<br />Zip Code: <input type="text" size="9" name="Zip" maxlength="5"><br />
<input type="submit" value="Search for Providers">
</form>
This works for me:
<form action="http://search1.bestbenefits.com/provsearch.asp" method="post" name="frmSearch" id="frmSearch" target="_blank" onSubmit="return CheckParams()">
<input type="hidden" name="Products" value="">
<input type="hidden" name="Title" value="24-7_MedPlan-20140416">
<input checked="checked" type="radio" name="RProducts" onclick="frmSearch.Products.value='BB'">Search Providers
<br />Zip Code: <input type="text" size="9" name="Zip" maxlength="5"><br />
<input type="submit" value="Search for Providers">
</form>
I have a servlet webapplication with jsp related to some servlets, among them, I have this form:
<form action="MeetingDetails" method="post">
<input type="hidden" name="mtgid" value="${selectMeeting.id}"/>
<c:forEach items="${comments}" var="comment" varStatus="i">
<p><input type="hidden" name="cmtid" value="${comment.getKey()}"/>
<c:out value="${comment.getKey()}"/> - <c:out value="${comment.getValue()}"/>
<input id="minus" type="submit" name="action" value="DeleteComment"/></p>
</c:forEach>
<p>New Comment: <input type="text" name="cmt" value=""> <input id="plus" type="submit" name="action" value="AddComment"/></p>
</form>
And when I send the action:Delete to the servlet, it recieves a wrong "cmtid" value, and if I put the form within the foreach, the parameter "mtgid" value is null...
Is there anyway to do this?
Thank you.
Sorry for the inconvenient, I figured it out by:
<c:forEach items="${comments}" var="comment" varStatus="i">
<form action="MeetingDetails" method="post">
<input type="hidden" name="mtgid" value="${selectMeeting.id}"/>
<p><input type="hidden" name="cmtid" value="${comment.getKey()}"/>
<c:out value="${comment.getKey()}"/> - <c:out value="${comment.getValue()}"/>
<input id="minus" type="submit" name="action" value="DeleteComment"/></p>
</form>
</c:forEach>
<form action="MeetingDetails" method="post">
<input type="hidden" name="mtgid" value="${selectMeeting.id}"/>
<p>New Comment: <input type="text" name="cmt" value=""> <input id="plus" type="submit" name="action" value="AddComment"/></p>
</form>
I was a little obfuscated and didn't see it
I am designing a JSP page with form action.
<form action="" method="post">
Username: <input type="textfield" name="username" />
Country : <input type="textfield" name="country" />
Url : <input type="textfield" name="Url" />
<input type="submit" value="Submit" />
</form>
I want to set the user given URL value in form action when I click the Submit button and redirect to that URL. How can I achieve this?
This can work pretty well
<form action="" method="post" id="myForm">
Username: <input type="text" name="username" />
Country : <input type="text" name="country" />
Url : <input id="url" type="text" name="Url" />
<button onclick="doStuff();">Submit</button>
</form>
<script>
function doStuff(){
$('#myForm').attr('action', $('#url').val());
$('#myForm').submit();
}
</script>
Don't forget to include the JQuery api's in your code:
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
I have two forms with different values in one page.
I want get input value of the form that user clicks on it's submit button, using mootools code.
Mootools code most work for two forms, as same:
<form class="cart_form" >
<input type="hidden" name="order_code" value="KWL-hgy" />
<input type="hidden" name="price" value="40000" />
<input type="hidden" name="name" value="modeling" />
<label>KWL-hgy: <input class="center" type="text" name="qty" value="2" size="3" ></label>
<input type="submit" name="submit" value="Add to cart" />
</form>
<form class="cart_form" >
<input type="hidden" name="order_code" value="KWL-JFE" />
<input type="hidden" name="price" value="12000" />
<input type="hidden" name="name" value="php" />
<label>KWL-JFE: <input class="center" type="text" name="qty" value="1" size="3" ></label>
<input type="submit" name="submit" value="Add to cart" />
</form>
you could do it somehow like this:
$$('form.cart_form').addEvent('submit', function(e){
this.getChildren().each(function(el){
alert(el.get('name') + ': ' + el.get('value'));
});
});
this will fire an event as soon as a form with the class chart_form is submited and loop through all the form's children.