Forums
This topic is locked
Javascript maybe???
Posted 28 May 2003 09:16:44
1
has voted
28 May 2003 09:16:44 Jelle-Jacob de Vries posted:
Hi everybody,I think I need a javascript for the following problem. I could use some ASP, but that would mean that the page has to ben sent to server again, and for some reasons I can't do that.
I'm using a listmenu where people can select a car brand. But if the car brand that the need isn't available in the list, the can enter the car brand in a textfield.
I know I can't piont two form elements to the same column in the database. So I thought, let's create a hiddenfield with some clever javascript that checks if the textfield contains any text. If yes put the value of the textfield in the hiddenfield. If it doesn't put the value of the listmenu in the hiddenfield.
Then bind the hiddenfield in the insert record behaviour and the mystery is solved. But now comes my problem, how can I do this??????
I hope someone can help me out.
Replies
Replied 11 Jun 2003 22:26:04
11 Jun 2003 22:26:04 Scott Burtscher replied:
I would create a function that resembles the one below and call it as an onChange event on your input field.
For my purposes your hidden field id will be refered to as "carHidden", your text field id will be refered to as "carInput" and your select menu id will be "carSelect"
Call the function like this:
<input type="text" id="carSelect" onChange="setMyCar()">
Put the function below in the document head
function setMyCar(){
var x=document.getElementByID("carInput"
var y=document.getElementById("carHidden"
var z=document.getElementById("carSelect"
if (x.value<>""{
y.value=x.value;
z.disabled=true;
}
}
See if this works for you.
For my purposes your hidden field id will be refered to as "carHidden", your text field id will be refered to as "carInput" and your select menu id will be "carSelect"
Call the function like this:
<input type="text" id="carSelect" onChange="setMyCar()">
Put the function below in the document head
function setMyCar(){
var x=document.getElementByID("carInput"
var y=document.getElementById("carHidden"
var z=document.getElementById("carSelect"
if (x.value<>""{
y.value=x.value;
z.disabled=true;
}
}
See if this works for you.