Forum Moderators: open
Basically, I am looking for a way to build the URL from the entry made in the FORM.
Any thoughts are greatly appreciated.
Steven Hill
Martin, GA USA
I'm not sure if I'm getting your problem, why'd you want to have your form submit to a url which is then translated by mod_rewrite to what the form would originally call anyway?
nevertheless, you might try this:
<input type="button" onClick="callZip()" value="submit" />
<script type="text/javascript">
function callZip() {
var zip = document.zipform.ZIP_Code;
var loc = '/' + zip.value + '_z_site.html';
document.location.href = loc;
}
</script>
Hope I could help you along.
<p>
<h4>Dealers by<br/>ZIP Code</h4>
<script language="JavaScript">
document.write('<form name="ZipForm">');
</script>
<noscript>
<form action="{$homeLink}/index.php"
name="ZipForm"
method="get">
</noscript>
<input type="text"
name="ZIP_Code"
size="5"
maxlength="5"
value="">
</input>
<script language="JavaScript">
document.write('<input type="button"');
document.write(' onClick = "location.href');
document.write(' = document.ZipForm.ZIP_Code.value + \'_z_site.html\';"');
document.write(' value="Search">');
document.write('</input>');
</script>
<noscript>
<input type="submit"
value="Search">
</input>
</noscript>
</form>
</p>
alex77:: I want the URL to appear in the browser as the 99999_z_site.html because it just looks cleaner than having a URL with variables exposed.
Thanks for the reply though, and I hope that the solution I figured out does help others. Basically, it puts out one type of form if they have scripting turned on and another if they do not. Granted, without scripting I get the ugly URL, but at least in most cases it will appear as I would like it to. Without JavaScript, I would probably have to go through an intermediate php script that would simply take the passed variable and reformat the URL an silently redirect to the new URL. I am not sure I want to go through that.
Steven Hill
Martin, GA USA