Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

pass input textbox value to another cfm file

New Here ,
Mar 13, 2007 Mar 13, 2007
How do I pass the value entered into a textbox in one cfm form to another that will query a databse and display the results?
thanks
2.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 14, 2007 Mar 14, 2007
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 14, 2007 Mar 14, 2007
quote:

Originally posted by: dzambo4114
How do I pass the value entered into a textbox in one cfm form to another that will query a databse and display the results?
thanks

Submit the form.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 14, 2007 Mar 14, 2007
Here's what I have tried:

form page

<!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>

<!--- <form method="post" name="lookup" action="cdm_player_detail.cfm?cdmid=7"> --->

<body onload="focus();lookup.playerid.focus()">
<form method="post" name="lookup" action="cdm_player_detail.cfm?#lookup.playerid#">
<input type="textbox" name="playerid"</>
<input type="submit" value="Search"</>
<input type="button" value="Clear"</>
</form>
</body>
</html>

query form

<cfparam name="URL.CDMID" default="1">
<cfquery name="GetPlayers" datasource="cdmbb">
select *
from tbl_Players
where CDMID = #URL.CDMID#
</cfquery>

<!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>

<table border="1" wifth="90%" >
<tr>
<td>CDMID</td>
<td>Name</td>
<td>Team</td>
<td>Salary</td>
<td>Pos</td>
</tr>
<cfoutput query="GetPlayers">
<tr>
<td>#GetPlayers.CDMID#</td>
<td>#GetPlayers.Player#</td>
<td>#GetPlayers.Team#</td>
<td>#GetPlayers.Salary#</td>
<td>#GetPlayers.Pos#</td>
</tr>
</cfoutput>
</table>

<body>
</body>
</html>

returns the first record in the table, not the desired record.

new to CF, thanks for your help.
Doug
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 23, 2007 Mar 23, 2007
LATEST
quote:

<form method="post" name="lookup" action="cdm_player_detail.cfm?#lookup.playerid#">


Instead of this action that you have listed, why not try

action="cdm_player_detail.cfm?playerid=#FORM.playerid#"

and then in your query on cdm_player_detail.cfm page, use WHERE playerid = '#URL.playerid#'
That will query all results based on the playerid from the form on the previous page.

Of course, make sure to validate the page by making sure a URL.playerid exists. This should be taken care of on the form page.

Lastly, your query on the results page is using a WHERE CDMID = '#URL.CDMID#' but by your code, you have commented out your URL.CDMID and instead are using playerid. I'm not sure which you are wanting to use, but judging by your form, you want to use playerid since you are actually submitting that variable. So use my above suggestion.

quote:

Originally posted by: Dan Bracuk
You're problem is here:
<form method="post" name="lookup" action="cdm_player_detail.cfm?#lookup.playerid#">

Make the playerid a hidden form field. That way all your variables on the action page will be in the form scope.



Since his form is submitting a playerid, he doesn't need to make a hidden field for playerid so long as he redirects his URL to FORM.playerid ... atleast that's my thinking on things unless i'm not seeing something right.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 14, 2007 Mar 14, 2007
You're problem is here:
<form method="post" name="lookup" action="cdm_player_detail.cfm?#lookup.playerid#">

Make the playerid a hidden form field. That way all your variables on the action page will be in the form scope.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources