mcmuney Posted August 7, 2008 Share Posted August 7, 2008 I'm trying to figure out the direct url of the form result page. The code below returns the form results; however, the url remains unchanged. For example, on domain.com, on submit, it remains as domain.com, but it returns form results. I'd like to know the direct path of the result page. I've tried domain.com/index.php?url=abc.com and a few others, but none work. <script type="text/javascript"> function validate_url(o,e){ //var patu = /^(((ht|f)tp(s?))\:\/\/)?(www.|[a-zA-Z].)[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,4}){1,2}(\:[0-9]+)*(\/($|[a-zA-Z0-9\.\,\;\?\'\\\+&%\$#\=~_\-]+))*$/i; //var patd = /^[a-zA-Z][a-zA-Z0-9]+(\.[a-zA-Z0-9]+)+$/i; var patu = /^(((ht|f)tp(s?))\:\/\/)?(www.|[a-zA-Z0-9].)[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,4}){1,2}(\:[0-9]+)*(\/($|[a-zA-Z0-9\.\,\;\?\'\\\+&%\$#\=~_\-]+))*$/i; var patd = /^[a-zA-Z0-9][a-zA-Z0-9]+(\.[a-zA-Z0-9]+)+$/i; R=$("#frm1url").val(); if(R && R.length>0 && R.match(patu)!=null){ return true; }else if(R && R.length>0 && R.match(patd)!=null){ return true; }else{ alert("Invalid url entered"); return false; } } </script> <form action="index.php" method="post" onsubmit="return validate_url(this,event)" style="padding:0px;margin:0px;"> <div id="search" style="padding:20px; width: 700px;"> <input class="input" type="text" name="url" id="frm1url" size="52" style="padding:5px;" value="Enter domain name or web page address" onblur="if (this.value == '') {this.value = 'Enter domain name or web page address';}" onfocus="if (this.value == 'Enter domain name or web page address') {this.value = '';}"> </div> </form> Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 7, 2008 Share Posted August 7, 2008 The form is using the POST method which doesn't show anything in the URL. If you want those variables to show up in the URL, you can change the method property to method="get". Of course, you will have to change how the php hangles the data. Quote Link to comment Share on other sites More sharing options...
True`Logic Posted August 8, 2008 Share Posted August 8, 2008 there are several ways to get form data with javascript, when using method=get (default if you just remove the "method" statement from the form tag) you can take location.url, split it at "?", take the second value and split it at "&", then take each value seperately, split them at "=" limitting to 1 split and parsing those values into variable=value... and in method=post with SOME webservers javascript can do a request(ID) to get the value (such as on the first page <input type=text id=username> and on the second page <script> vart user = request('username');document.write("Hello there " + user); </script> hope this helped... theres form validation for method=get on javascriptkit.com i think. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.