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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I retain my data within a text box?

Status
Not open for further replies.

soho34

IS-IT--Management
Dec 28, 2004
102
US
Hi,

I have a form that has 2 text boxes. I'm not very saavy on <div>, but these input boxes are wrapped in <div> tags as follows:

Code:
 	 <td>
	  	 <div id="tempid" style="font-size:12px;"><br>
         <input type="text" name="tempid" onChange="settemp(this.value);" value="<cfoutput>#GetTemps.tempid#</cfoutput>">
		 </div>

      </td>
   	  <td>
   		<div id="fullname" style="font-size:12px;"><br>
         <input type="text" name="tempName" value="<cfoutput>#GetTemps.tempname#</cfoutput>">
		 </div>
   	  </td>

Notice in the first text box, there's a call to a function settemp(this.value). This function makes a call to another file that's a ColdFusion file that performs some server-side processing to obtain current results.

I want those current results returned to my input boxes.
The return work fine, but when the update happens, instead of returning the updated information within my text boxes, it gives me the updated information outside the box.

Here's my logic from the (.cfm) file in case you need it.

Code:
...query performed here
<cfoutput>
		<script type="text/javascript">
		parent.tempid.innerHTML = "#getTempName.tempid#";
		parent.fullname.innerHTML = "#getTempName.fullname#";
		</script>
		
		
</cfoutput>

I'm assuming this is a <div> or CSS type question. That's why I didn't post on the CF forum.

Is there a way to update the text boxes with the information returned?

I also tried assigning an id within the <input> tag, but it still returns data at the top of the box.

Thanks in advance for any help.

soho34
 
Make sure you have a form that your inputs are in, then do this:

Code:
        <script type="text/javascript">
        document.theformsname.tempid.value = "#getTempName.tempid#";
        document.theformsname.fullname.value = "#getTempName.fullname#";
        </script>

That should work, just remember to change "theformsname" to the form's name.

Rick

 
Think I answered my own question.

I'll post for someone else in case they're stuck.

In my HTML file, change my text boxes to have their own ids:

Code:
<td>     
<input id="tempid" type="text" name="tempid" onChange="settemp(this.value);" value="<cfoutput>#GetTemps.tempid#</cfoutput>">
</td>
<td>
<input id="fullname" type="text" name="tempName" value="<cfoutput>#GetTemps.tempname#</cfoutput>">
</td>

Next, in my file that does the processing, make sure you put the .value at the end of the line.

Code:
<script type="text/javascript">
				parent.ordertemp4.tempid.value= "#getTempName.tempid#";
		parent.ordertemp4.fullname.value= "#getTempName.fullname#";
</script>

[thumbsup2]
 
Hi Ristmo,

Thanks for the post. We must've posted at the same time. Strange, huh?

Thanks again.

soho34
 
Hi,

Now I'm trying to populate a select box in a similar way.

I come into my main page, and I have a <select> complete with options.
Code:
<select id="vendorname" name="vendorname">
			<cfloop query="getvendors">
				<option value="#getvendors.vendorid#" <cfif #getvendors.vendorid# eq #oneservice.vendorid#>selected</cfif>>
					 #getvendors.name#
				</option>
			</cfloop>
</select>

This is fine, however, this select is dependent on another select box above it that, when its value is changed, calls another template, shown below.


I basically have a standard query named "getServiceVendors" that has fields: vendorid and name

How can I populate/update my select box above with my values from this template?

Thanks in advance for any suggestions.

soho34
 
I'm sorry, I don't quite understand? You have two select boxes....you want the options in the second to change depending on the selected value in the first?

Rick

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top