Question
Submit Button Vs anchor tag
Hello Everyone,
I am facing a problem with regarding to passing variables from one page to another using <a href>. I was trying the sample code as below:
index.cfm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<script language="javascript">
function saySomething(arg)
{
document.myform.firstname.value = arg;
var last = document.myform.lastname.value;
alert(document.myform.lastname.value);
}
</script>
<body>
<form method="post" action="index1.cfm" name="myform">
<input type="text" name="firstname" id="firstname" value=""/>
<input type="text" name="lastname" id="lastname" value=""/>
<a href="index1.cfm" onclick="saySomething('me')">Click here</a>
</form>
</body>
</html>
index1.cfm
<cfoutput>Hello</cfoutput>
<cfparam name="myvariable" default="lavanya">
<cfif isdefined("form.firstname")>
<cfset myvariable = #form.firstname#>
</cfif>
<cfoutput>#myvariable#</cfoutput>
<cfoutput>#form.lastname#</cfoutput>
I am not able to retreive the value from the previous page. But when I replace the <A href> with the submit button, all works fine...How can I make it possible using <a href>?
I am facing a problem with regarding to passing variables from one page to another using <a href>. I was trying the sample code as below:
index.cfm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<script language="javascript">
function saySomething(arg)
{
document.myform.firstname.value = arg;
var last = document.myform.lastname.value;
alert(document.myform.lastname.value);
}
</script>
<body>
<form method="post" action="index1.cfm" name="myform">
<input type="text" name="firstname" id="firstname" value=""/>
<input type="text" name="lastname" id="lastname" value=""/>
<a href="index1.cfm" onclick="saySomething('me')">Click here</a>
</form>
</body>
</html>
index1.cfm
<cfoutput>Hello</cfoutput>
<cfparam name="myvariable" default="lavanya">
<cfif isdefined("form.firstname")>
<cfset myvariable = #form.firstname#>
</cfif>
<cfoutput>#myvariable#</cfoutput>
<cfoutput>#form.lastname#</cfoutput>
I am not able to retreive the value from the previous page. But when I replace the <A href> with the submit button, all works fine...How can I make it possible using <a href>?
