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

Update Hidden Value on the Fly?

Status
Not open for further replies.

Reynet01

Technical User
Apr 27, 2004
59
US
I have a form with input input fields
1. A drop down box of current customers "ClientSelect"
2. a text field to enter new customers "Clienttext"
3. A hidden field "ClientHidden" Below is the value for this field

<input name="clienthidden" type="hidden" id="clienthidden" value="<% If request.form("ClientSelect")="NONE" then Response.write request.form("clienttext") Else response.write request.form("clientselect")end if%>">

Whenever the form is submitted the Client data is blank. My queston is how would I automatically update the hidden value when someone either selects a existing Client or enters a new client. Basically Update the hidden field value before I submit.

If knowledge were power I would be a AAA battery!
 
You need to use Javascript on the client to achieve this. The following should give you a clue about how to go about this:

Code:
  <script language='javascript'>
function setNameFromSelect(sel) {
	document.getElementById('clientText').value=sel.options[sel.selectedIndex].text;
}

function setNameFromInput(inp) {
	document.getElementById('clientText').value=inp.value;
}
  </script>
  <select onchange='setNameFromSelect(this)' ...>
  <input onchange='setNameFromInput(this)'  ...>

You might get more help from the Javascript forum as well.

Chaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top