Click to See Complete Forum and Search --> : radio button action change
Fire Cat
09-08-2009, 12:07 PM
Hey everybody,
I am making a search for my website and I have a form. The problem is , there are radio button for file search, image search... but the search code is in a different file, so I need that the form action changes when I select a different radio button
Thanks!
cbVision
09-08-2009, 12:45 PM
You could use jQuery to do something like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Title</title>
<meta name="language" content="en" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<style type="text/css">
/* Insert styles here */
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function(){
var action1 = 'action1.php';
var action2 = 'action2.php';
var action3 = 'action3.php';
$('#action1').click(function(){
$('#testform').attr('action', action1);
});
$('#action2').click(function(){
$('#testform').attr('action', action2);
});
$('#action3').click(function(){
$('#testform').attr('action', action3);
});
});
//]]>
</script>
</head>
<body>
<h1>Test</h1>
<form action="" method="post" id="testform">
Action 1 <input type="radio" id="action1" />
Action 2 <input type="radio" id="action2" />
Action 3 <input type="radio" id="action3" />
<input type="submit">
</form>
</body>
</html>