页面刷新或页面重新加载. [英] Page refresh or page reload..

查看:125
本文介绍了页面刷新或页面重新加载.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


大家好,我需要帮助以防止页面刷新或重新加载.

我有一个页面作为联系方式.
而且我在每个文本框上都放了Java脚本.
但是在提交安全密码后,即使密码错误,它也会刷新页面并丢失所有文本框数据.

我只希望如果代码错误,它将保留在同一页面中,而文本框的数据将保留为已填充状态,仅安全代码文本框显示为空白.

我已经将所有代码都发送到了同一页面..

请仔细检查一下,并帮助我解决..
非常紧急...

在此先感谢....

Hi,
Hello every one, i need a help to prevent page refresh or reload.

I have a page as contact details.
and i have put java script on every textbox.
but after submitting the security code it refresh the page and all textboxes data lost, even if the code is wrong.

i only want that if the code is wrong it remain in the same page and data of textboxes remain as it was filled only security code textbox show blank.

I have sent you all the code it is in the same page..

pls go through it and help me to solve it..
its very urgent...

thanks in advance....

<script type="text/javascript">
function form_validation()
{

hh=document.WebToLeadForm;

    	if(hh.first_name.value==""){
		alert("Please enter your first name.");
		hh.first_name.focus();
		return false;
	}
	
	if(hh.last_name.value==""){
		alert("Please enter your last name.");
		hh.last_name.focus();
		return false;
	}
	
	if(hh.account_name.value==""){
		alert("Please enter company name.");
		hh.account_name.focus();
		return false;
	}
	
	
if(hh.webtolead_email1.value==""){
		alert("Please enter your email address");
		hh.webtolead_email1.focus();
		return false;
	}
	if (hh.webtolead_email1.value.indexOf('@') == -1){
		alert("Invalid email address");
		hh.webtolead_email1.focus();
		return false;
	}
	
		
	if (hh.webtolead_email1.value.indexOf('.') == -1){
		alert("Invalid email address");
		hh.webtolead_email1.focus();
		return false;
	}
	
	
		
	if(document.getElementById("phone").value.length < 10)
 {
 alert('Enter your mobile number');
 document.getElementById("phone").focus();
 return false;
	
}
if (isNaN(parseInt(document.getElementById("phone").value))) 
{
        alert('Only Numbers are Allowed');
		 document.getElementById("phone").focus();
		return false;

}

if(hh.product.value==""){
		alert("Please select Product Interest.");
		hh.product.focus();
		return false;
	}
if(hh.description.value==""){
		alert("Please enter description");
		hh.description.focus();
		return false;
}

//alert("Thank you for your Enquiry. Our representative will contact you shortly. Please press Ok.");
	

}
</script>


<table width="220" border="0" align="center" cellpadding="0" cellspacing="0" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; color:#4c4c4c;">
<form action="<?php echo $_SERVER['PHP_SELF'];??>" name="WebToLeadForm" method="post" id="WebToLeadForm" onsubmit="javascript: return form_validation();" >
                      <tr>
                        <td height="30">First Name: <span class="required" style="color:#93B928;">*</span></td>
                        <td><input id="first_name" name="first_name" type="text" style="width:100px;" /></td>
                      </tr>
                      <tr>
                        <td height="30"><span sugar="slot">Last Name: </span> <span class="required" style="color:#93B928;">*</span></td>
                        <td><span sugar="slot">
                          <input id="last_name" name="last_name" type="text" style="width:100px;"/>
                          </span> </td>
                      </tr>
                      <tr>
                        <td height="30">Company Name: <span class="required" style="color:#93B928;">*</span></td>
                        <td><span sugar="slot">
                          <input id="account_name" name="account_name" type="text" style="width:100px;"/>
                          </span> </td>
                      </tr>
                      <tr>
                        <td height="30">Email: <span class="required" style="color:#93B928;">*</span></td>
                        <td><span sugar="slot">
                          <input id="webtolead_email1" name="webtolead_email1" onchange="validateEmailAdd();" type="text" style="width:100px;" />
                          </span></td>
                      </tr>
                      <tr>
                        <td height="30" valign="top">Contact Number:<span class="required" style="color:#93B928;">*</span></td>
                        <td valign="top"><input id="phone" name="phone" type="text" style="width:100px;" />
                        </td>
                      </tr>
                      
                       <tr>
                        <td height="30" valign="top">Product Interest:<span class="required" style="color:#93B928;">*</span></td>
                        <td valign="top"><select name="product" id="product" style="width:100px;">
                    <option selected="selected" value="">------None------</option>
                    <option value="System 444"> System 444</option>
                    <option value=" System Lite">System Lite</option>
                    <option value="System Duo">System Duo</option>
                    <option value="System Plus">System Plus</option>
                   
                  </select>
                        </td>
                      </tr>
                      
                      <tr>
                        <td height="30" valign="top">Detail:<span class="required" style="color:#93B928;">*</span></td>
                        <td valign="top"><textarea name="description" id="description" cols="25" rows="5" style="width:100px;"></textarea></td>
                      </tr>



<tr>
                        <td height="30" valign="top"> </td>
                        <td valign="top"><img id="imgid" src="CaptchaSecurityImages.php?width=100&height=40&characters=5" /></td>
                      </tr>
                      <tr>
                        <td height="30" valign="top"><small>Can't read the image?</small> </td>
                        <td valign="top">click <a href="java<!-- no -->script: refreshCaptcha();"><small>here</small></a><small>to refresh</small></td>
                      </tr>
						<tr>
                        <td height="30" valign="top">Security Code:<span class="required" style="color:#93B928;">*</span></td>
                        <td valign="top"><input id="security_code" name="security_code" type="text" style="width:100px;"/></td>
                      </tr>
                    <tr>
                        <td height="50" valign="top"> </td>
                        <td valign="top"><input class="button" name="Submit" value="Send" type="submit" /></td>
                      </tr>
                      <tr>
                        <td height="30" valign="top">Security Code:<span class="required" style="color:#93B928;">*</span></td>
                        <td valign="top"><input id="code" name="code" type="text" value="<?php if(!empty($_SESSION["msg"])) echo($_SESSION["msg"]); ??>" style="width:100px;"/></td>
                      </tr>
                      
                    </form>
                    </table>





 <?php <br mode="hold" /?>//session_start();

if(isset($_POST['Submit'])) {
   if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) {
		// Insert you code for processing the form here, e.g emailing the submission, entering it into a database. 
		//echo 'Thank you. Your message said "'.$_POST['message'].'"';
	//echo 'Thank you. Your message said "';
	$_SESSION['first_name'] = $_POST['first_name'];
    $_SESSION['last_name'] = $_POST['last_name'];
	$_SESSION['account_name'] = $_POST['account_name'];
	$_SESSION['webtolead_email1'] = $_POST['webtolead_email1'];
	$_SESSION['phone'] = $_POST['phone'];
	$_SESSION['product'] = $_POST['product'];
	$_SESSION['description'] = $_POST['description'];
	echo "<script>alert('Thank you...')</script>";
	header( 'Location:http://localhost/MySQL/test.php' ) ;
	unset($_SESSION['security_code']);

    } 
   else {
		 //Insert your code for showing an error message here
		
		echo "<script>alert('Please check the code...')</script>";
	//echo 'Sorry, you have provided an invalid security code';
		//header( 'Location:http://localhost/MySQL/captcha.php' ) ;
	   }
} 
else {
//echo 'Sorry, you have provided andasfasdfadfasdfasdde';
}
?>

推荐答案

_SERVER['PHP_SELF'];??>" name="WebToLeadForm" method="post" id="WebToLeadForm" onsubmit="javascript: return form_validation();" > < tr > <td height="30">First Name: <span class="required" style="color:#93B928;">*</span></td> <td><input id="first_name" name="first_name" type="text" style="width:100px;" /></td> < /tr > < tr > <td height="30"><span sugar="slot">Last Name: </span> <span class="required" style="color:#93B928;">*</span></td> <td><span sugar="slot"> <input id="last_name" name="last_name" type="text" style="width:100px;"/> < /span > < /td > < /tr > < tr > <td height="30">Company Name: <span class="required" style="color:#93B928;">*</span></td> <td><span sugar="slot"> <input id="account_name" name="account_name" type="text" style="width:100px;"/> < /span > < /td > < /tr > < tr > <td height="30">Email: <span class="required" style="color:#93B928;">*</span></td> <td><span sugar="slot"> <input id="webtolead_email1" name="webtolead_email1" onchange="validateEmailAdd();" type="text" style="width:100px;" /> </span></td> < /tr > < tr > <td height="30" valign="top">Contact Number:<span class="required" style="color:#93B928;">*</span> < /td > <td valign="top"><input id="phone" name="phone" type="text" style="width:100px;" / > < /td > < /tr > < tr > <td height="30" valign="top">Product Interest:<span class="required" style="color:#93B928;">*</span></td> <td valign="top"><select name="product" id="product" style="width:100px;"> <option selected="selected" value="">------None------</option> <option value="System 444"> System 444</option> <option value=" System Lite">System Lite</option> <option value="System Duo">System Duo</option> <option value="System Plus">System Plus</option> < /select > < /td > < /tr > < tr > <td height="30" valign="top">Detail:<span class="required" style="color:#93B928;">*</span></td> <td valign="top"><textarea name="description" id="description" cols="25" rows="5" style="width:100px;"></textarea></td> < /tr > < tr > <td height="30" valign="top"> </td> <td valign="top"><img id="imgid" src="CaptchaSecurityImages.php?width=100&height=40&characters=5" /></td> < /tr > < tr > <td height="30" valign="top"><small>Can't read the image?</small> </td> <td valign="top">click <a href="java<!-- no -->script: refreshCaptcha();"><small>here</small></a><small>to refresh</small></td> < /tr > < tr > <td height="30" valign="top">Security Code:<span class="required" style="color:#93B928;">*</span>< /td > < td =" top" < id =" 名称 =" 类型 =" 样式 =" 宽度:100px;" > /td < /tr > < tr > <td height="50" valign="top"> </td> < td =" top" < =" 名称 =" 类型 =" / > < /td > < /tr > < tr > <td height="30" valign="top">Security Code:<span class="required" style="color:#93B928;">*</span>< /td > <td valign="top"><input id="code" name="code" type="text" value="<?php if(!empty(
_SERVER['PHP_SELF'];??>" name="WebToLeadForm" method="post" id="WebToLeadForm" onsubmit="javascript: return form_validation();" > <tr> <td height="30">First Name: <span class="required" style="color:#93B928;">*</span></td> <td><input id="first_name" name="first_name" type="text" style="width:100px;" /></td> </tr> <tr> <td height="30"><span sugar="slot">Last Name: </span> <span class="required" style="color:#93B928;">*</span></td> <td><span sugar="slot"> <input id="last_name" name="last_name" type="text" style="width:100px;"/> </span> </td> </tr> <tr> <td height="30">Company Name: <span class="required" style="color:#93B928;">*</span></td> <td><span sugar="slot"> <input id="account_name" name="account_name" type="text" style="width:100px;"/> </span> </td> </tr> <tr> <td height="30">Email: <span class="required" style="color:#93B928;">*</span></td> <td><span sugar="slot"> <input id="webtolead_email1" name="webtolead_email1" onchange="validateEmailAdd();" type="text" style="width:100px;" /> </span></td> </tr> <tr> <td height="30" valign="top">Contact Number:<span class="required" style="color:#93B928;">*</span></td> <td valign="top"><input id="phone" name="phone" type="text" style="width:100px;" /> </td> </tr> <tr> <td height="30" valign="top">Product Interest:<span class="required" style="color:#93B928;">*</span></td> <td valign="top"><select name="product" id="product" style="width:100px;"> <option selected="selected" value="">------None------</option> <option value="System 444"> System 444</option> <option value=" System Lite">System Lite</option> <option value="System Duo">System Duo</option> <option value="System Plus">System Plus</option> </select> </td> </tr> <tr> <td height="30" valign="top">Detail:<span class="required" style="color:#93B928;">*</span></td> <td valign="top"><textarea name="description" id="description" cols="25" rows="5" style="width:100px;"></textarea></td> </tr> <tr> <td height="30" valign="top"> </td> <td valign="top"><img id="imgid" src="CaptchaSecurityImages.php?width=100&height=40&characters=5" /></td> </tr> <tr> <td height="30" valign="top"><small>Can't read the image?</small> </td> <td valign="top">click <a href="java<!-- no -->script: refreshCaptcha();"><small>here</small></a><small>to refresh</small></td> </tr> <tr> <td height="30" valign="top">Security Code:<span class="required" style="color:#93B928;">*</span></td> <td valign="top"><input id="security_code" name="security_code" type="text" style="width:100px;"/></td> </tr> <tr> <td height="50" valign="top"> </td> <td valign="top"><input class="button" name="Submit" value="Send" type="submit" /></td> </tr> <tr> <td height="30" valign="top">Security Code:<span class="required" style="color:#93B928;">*</span></td> <td valign="top"><input id="code" name="code" type="text" value="<?php if(!empty(


_SESSION["msg"])) echo(
_SESSION["msg"])) echo(


_SESSION["msg"]); ??>" style="width:100px;"/></td> < /tr > < /form > < /table >
_SESSION["msg"]); ??>" style="width:100px;"/></td> </tr> </form> </table>





 <?php <br mode="hold" /?>//session_start();

if(isset(


这篇关于页面刷新或页面重新加载.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆