I am using the following form to take input and then set an action
<select name="page_option">
<option value="go1">GO1</option>
<option value="go2">Go 2</option>
</select>
<input type="submit" value="Change home.php" />
Instead of this I want to have two buttons side by side,one button has text GO1 while other has GO2 and when user click GO1 and GO2 it will serve the same purpose as this above form
Also when Go1 button is clicked the page will display below the buttons "GO1 is on" and when Go2 is clicked it will display below "GO2 is on"
Any clue ?
Try the following..
<form action='action.php' method='post'>
<input type="submit" name='go1' value="go1">
<input type="submit" name='go2' value="go2">
in action.php
if(isset($_REQUEST['go1']))
{
$_SESSION['msg'] = 'Go1 button is on'
}
if(isset($_REQUEST['go2']))
{
$_SESSION['msg'] = 'Go2 button is on'
}
print_r($_SESSION['msg']);
Hope this will help you. You must start session at the beginning of action.php file
Thanks
You can have two submit buttons, as follows:
<input type="submit" value="go1">
<input type="submit" value="go2">
You can check serverside which button was clicked, and lead the user to the appropriate page.
<form action="form_action.asp" method="get">
<select name="page_option">
<option value="go1">GO1</option>
<option value="go2">Go 2</option>
</select>
<input type="submit" value="Submit" />
</form>
action="form_action.asp" method="get"
then use java script
<input type="submit" onclick="function1()" value="go1">
<input type="submit" onclick="function2()" value="go2">
funcation f1(){}
funcation f2(){}
Related
Having trouble getting this code to actually close a window. Can anyone help? When the "return" is clicked it just goes to a blank page.
<form method="post" action="http://ww8.aitsafe.com/cf/add.cfm" target="newWindow" onsubmit="window.open('', 'newWindow','width=800,height=500,'+'scrollbars=yes,status=no,toolbar=no,menubar=no,top=200,left=200')">
<p>
<input type="hidden" name="userid" value="A8403475">
<input type="hidden" name="return" value="window.close">
<input type="hidden" name="thumb" value="logo.png">
<select name="productpr">
<option>- Select Size -</option>
<option value="Size one:9.99">Size one - 9.99</option>
<option value="Size two:12.99">Size two - 12.99</option>
</select>
<input type="submit" value="Add to Cart">
</p>
</form>
Defining your code as a value of hidden input field will do nothing in this case.
Create a button and do something similar to this: <button type="button" onclick="window.close();">Close</button>
You didn't specify when you want the window to be closed...
<form method="post" action="/page/?foo=ABC">
<select name="foo">
<option value="ABC">ABC</option>
<option value="DEF">DEF</option>
</select>
<select name="bar">
<option value="GHI">GHI</option>
<option value="JKL">JKL</option>
</select>
<input id="search" type="text" placeholder="Search">
<input type="submit" value="">
</form>
I have the above form on a Wordpress site. If I go to /page/?foo=ABC, this page shows me everything as it should where foo = ABC.
What do I need to set the action as to get the option from the select?
Your form needs to use GET instead of POST:
<form method="get" action="/page/">
Then then all the inputs will be appended to the URL in the manner you seek.
As Marc B said in the comments, use
$_POST['foo']
i have a dropdown form but its not working when i want to submit it.
Here it is:
<form name="subselect">
<select name="menu">
<option selected="selected" value="javascript:void(0)">Select Payment Period</option>
<option value="http://1.com">Every 3 Months</option>
<option value="http://2.com">Every 6 Months</option>
<option value="http://3.com">Every 12 Months</option>
<option value="http://4.com">Every 24 Months</option>
</select>
<li class="pricing_footer"><a onclick="window.document.location.href=this.options[this.selectedIndex].value;" value="GO" class="pricing_button">Purchase</a></li>
</form>
it works like so:
<select name="menu" onChange="window.document.location.href=this.options[this.selectedIndex].value;" value="GO">
but i want a separate button to be the submit one.
Use a button:
<button>Submit</button>
Or an input (type=submit):
<input type="submit" value="Submit" />
You can use :
input type="submit" value="Submit
And you should use: form action="action_page.php method="GET" for your further action.
If you click "Submit", the form-data will be sent to a page called "action_page.php".
details: http://www.w3schools.com/html/html_forms.asp
Thanks guys!
I did the following thing, created a new script and assigned the submit button to it. I want the script to be able to open new url from the selected dropdown and it works now.
<script>function purchasefunc() {
var url=document.redirect.selection.value
document.location.href=url
}</script>
and the button
<a type=button value="Purchase" onClick="purchasefunc();" style="cursor: pointer;" class="pricing_button">Purchase</a>
try window.open(url)
or submit button change url onsubmit
I have a simple form that I want to pass the user selection via url.
<form method="GET" action="course-registration.asp">
<select>
<option value="#">--Select--</option>
<option value="courseOfferings[special_1005][item_1]=January%2030-31,%202014&course=ArcCHECK / 3DVH Product Training&date=January 30-31, 2013&description=This hands-on product training course focuses on the use of the ArcCHECK 3-dimensional beam dosimetry QA system with 3DVH software.">January 30-31, 2014</option>
</select>
<input type="submit" value="Submit">
</form>
If I alert the value of the select, it shows correctly, but it does not pass to the url when button is pressed.
You need to give a name to the select element
like <select name="dept">
<form method="GET" action="course-registration.asp">
<select name="something">
<option value="#">--Select--</option>
<option value="cof">January 30-31, 2014</option>
</select>
<input type="submit" value="Submit">
</form>
this will make your url lookblike "http://some.co/?something=manything"
I'm not a lot into HTML and I need some help.
I've a little listbox with 3 elements:
<select size="20">
<option>Spiderman</option>
<option>Superman</option>
<option>Hulk</option>
</select>
<input type="submit" value="Search!" />
What I want is if someone selects "Spiderman" and clicks on Search, I want him to go to the website "Spiderman.html". And the same with the rest ones, if he clicks on Superman, goes to Superman.html, and if he clicks on Hulk goes to Hulk.html.
Thanks.
try this :)
<select size="20" id="myselect" >
<option value="spiderman.html">Spiderman</option>
<option value="superman.html">Superman</option>
<option value="hulk.html">Hulk</option>
</select>
<input type="submit" value="Search!" onclick="document.location.href = 'http://your-website/' + document.getElementById('myselect').value;" />