views:

32

answers:

1

How do I pass a JS boolean to hidden CFINPUT field when a user has edited text in a specific input text field?

A: 

Let say this is your field

<input type="text" id="textbox1" value="abc def" name="somename1" onchange="passToHiddenField()" />

And this is your hidden input field

<input type="hidden" id="hidden1" name="somename2" value="" />

Then add the script function

<script>
function passToHiddenField(){
     document.getElementById('hidden1').value = 1; //do whatever you want in this function.
}
</script>
Bang Dao
The value of the hidden field would always be 1 then?
KooiInc
That's not that. The main thing I want to mention here is we can pass 1 (true) to the hidden field whenever the user edited the `#textbox1`. That why I comment on the function that we can do whatever we want in that function. You can see that the default value of `#hidden1` is nothing (false).
Bang Dao
Hi Bang Dao,I added all the fields like you mentioned above but the hidden input seems to stay empty. Here are the Scope Variables after making a change in the email field and submitting:Form Fields:PHONE_NUMBER=999-999-9999SOMENAME2=Here is my hidden field and email input:<input type="hidden" id="hidden1" name="somename2" value="" />Email Address: <input style="width: 100px;" name="EMAIL_ADDRESS" type="text" maxlength="40" value="<cfoutput>#EMAIL_ADDRESS#</cfoutput>" onchange="passToHiddenField()" />The JS call is in the top portion of the page.Why is it not submit value 1?
Alex
I'll try to find out
Bang Dao
Hi, I tested by myself and found nothing wrong in my code. Then it must be wrong somewhere else. Did you insert the js function to your page, the **passToHiddenField** function?
Bang Dao
Thanks Bang Dao - It worked :)
Alex