Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Text Box Info to Variable

Status
Not open for further replies.

sysadmin07

IS-IT--Management
Feb 20, 2007
41
US
Hi,

I'm currently working on a website consisting of three frames. The first frame contains a textbox and a submit button. When the user enters a zip code and hits "submit," search results are shown on the second frame (this is working okay and I don't need help with that, just an FYI). What I'd like to accomplish though is that when they hit the submit button, I'd also like their search terms to be entered onto a third frame's text area so that they can see their prior searches. Thus far, I have it set to output a string when the "submit" button is clicked, but would like to figure out how to change this to output the zipcode entered into the text field in the first frame.

I appreciate any comments. Thanks.

Here is my code for the form of the search box thus far:

Code:
<form TARGET="mapFrame" METHOD="POST" ACTION="results2.cfm">
	<table width="266" cellpadding="1" cellspacing="3">
		<tr><td colspan="3"><span class="style1 style1">Enter city (without the state) or 
           zip code </span></td>
           <tr>
                 <td width="154"><input type="TEXT" name="Textbox" /></td>    
                 <td width="56"><input name="submit" type="submit" value="Search" 
             //Section that outputs the word "submit" to my search terms frame.  I'd like to 
             change this to the value(s) entered in the search box		 
                   onClick="parent.resultsFrame.document.form1.text1.value=submit"/></td>
                  <td width="40"><input name="RESET" type="RESET" value="Reset" /></td>
        </table>
</form>

Here is the code for the form of the third frame that I'd like to output the search terms to:

Code:
<FORM name="form1">
<INPUT type="text" name="text1" size="25" value="">
</FORM>
 
[1] Do not name the submit button "submit". That creates a big confusion for scripting reference.

>Section that outputs the word "submit" to my search terms frame
[2] I don't see how the word "submit" is written out without quoting the right-hand-side submit?

[3]
><td width="56"><input name="submit" type="submit" value="Search"
//Section that outputs the word "submit" to my search terms frame. I'd like to
change this to the value(s) entered in the search box
onClick="parent.resultsFrame.document.form1.text1.value=submit"/></td>

[tt]
<td width="56"><input name="[blue]nameotherthan[/blue]submit" type="submit" value="Search" onClick="parent.resultsFrame.document.form1.text1.value=[red]this.form.Textbox.value[/red]"/></td>[/tt]
 
Thanks so much for your help. That worked!! However, I am now getting a Coldfusion error on "results2.cfm." It is directly attributed to the inclusion of the code that you wrote above, but I'm unsure why it's causing it. I've attached the form below for reference. You'll see that on the first line, the "ACTION="results2.cfm."

I really appreciate the help.

Code:
<form TARGET="mapFrame" METHOD="POST" ACTION="results2.cfm">
    <table width="266" cellpadding="1" cellspacing="3">
        <tr><td colspan="3"><span class="style1 style1">Enter city (without the state) or 
           zip code </span></td>
           <tr>
                 <td width="154"><input type="TEXT" name="Textbox" /></td>
                 <td width="56"><input name="test" type="submit" value="Search" 
			                          onClick="parent.resultsFrame.document.form1.text1.value=this.form.Textbox.value"/></td>
                  <td width="40"><input name="RESET" type="RESET" value="Reset" /></td></form>
    </table>
</form>
 
Why not put the onclick handler from the submit button in the onsubmit clause in the form:

Code:
<form TARGET="mapFrame" METHOD="POST" ACTION="results2.cfm" [!]onsubmit="parent.resultsFrame.document.form1.text1.value=this.form.Textbox.value"[/!]>

Code:
<td width="56"><input name="test" type="submit" value="Search" /></td>

That may take care of your coldfusion problem.




[small]"I see pretty girls everywhere I look, everywhere I look, everywhere I look. - Band song on movie "The Ringer"[/small]
<.
 
It seems <tr>s are not properly closed out.
 
dang tsuji, I didn't even pay attention to that.

[small]"I see pretty girls everywhere I look, everywhere I look, everywhere I look. - Band song on movie "The Ringer"[/small]
<.
 
And </table> and </form> are misplaced and there is a surplus </form>.
 
Thanks for the replies. Sorry about the <tr>s </table>s, and <form>s that were leftover. In my "live" code, those were removed, however, I copied from my code that I initally included in the post and not the lastest.

Anyways, I tried moving the JavaScript into the clause, as suggested by monksnake, but to no avail, the same Coldfusion error occurred. When the onclick handler is removed, everything works fine, but when it's added, the Coldfusion error arrives. Could it be from the "Search" button performing two tasks (e.g. sending the zipcode to the other frame and also sending the search criteria to results2.cfm)? Either way, I appreciate any more comments. You have all been very helpful.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top