...

View Full Version : onsubmit url



houhou
11-29-2012, 03:47 AM
hello

what i m trying to do is when i press submit, it will redirect me to a url with the values that i submited in the form ..

what wrong i m doing .. thanks in advance :)

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
label {
display:block;
}
</style>
<script type="text/javascript">
function goTo()
{

var city = document.forms[0].city.value;
var state = document.forms[0].state.value;
window.parent.location.href=url+'?city='+city+'&state='+state;
return false;
}
</script>
</head>
<body>
<form action="" method="get" onsubmit="return goTo()">

<label for="city">Enter the city:
<input type="text" name="city" id="city">
</label>
<label for="state">Enter the state:
<input type="state" name="state" id="state">
</label>
<input type="submit" value="Submit">
</form>
</body>
</html>

devnull69
11-29-2012, 07:08 AM
It is totally senseless to use Javascript for this. The functionality you describe is the basic functionality for HTML forms and can (and should) easily be accomplished using only HTML. But you are missing the URL, which you will have to add to the "action" attribute of the form


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
label {
display:block;
}
</style>
</head>
<body>
<form action="yoururl.php" method="get">

<label for="city">Enter the city:
<input type="text" name="city" id="city">
</label>
<label for="state">Enter the state:
<input type="state" name="state" id="state">
</label>
<input type="submit" value="Submit">
</form>
</body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum