close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

set field value with js

Thread began 5/10/2011 7:50 am by CraigR | Last modified 8/19/2011 2:31 am by CraigR | 1858 views | 4 replies

CraigRBeta Tester

set field value with js

I have a form where the customer has a number of search parameters, with radio buttons for 'all' and 'range'

When the page loads, the 'from' and 'to' labels and text input boxes are hidden and when the 'range' radio button is clicked, the div id in which these elements appear is set to display via a js function.
Conversely, when the 'all' radio button is clicked, the div is set to hidden.

Depending on the radio button selected, a different id passed to the function.

Something like this

<script type="text/javascript">
<!--
function visibility_off(id) {
var e = document.getElementById(id);
e.style.display = 'none';
}
//-->
<!--
function visibility_on(id) {
var e = document.getElementById(id);
e.style.display = 'block';
}
//-->
</script>

This works fine, however hiding the text input boxes doesn't clear their values.

I want to set the text inputs to an empty string when the 'all' radio button is selected and thought if i use the name of the div as the root, and append it with min and max respectively, this would work for me, but it doesn't.

eg lets call the id of the div element 'first'

passing 'first' into the function will do what i want

if i give my text boxes ids of 'firstmin' and 'firstmax' i want to use the div element name as the root and concatenate min and max onto the end.

eg.

<!--
function visibility_off(id) {
var e = document.getElementById(id);
e.style.display = 'none';
document.getElementById(id+'min').value = '';
document.getElementById(id+'max').value = '';
}
//-->



This will allow me to use the same function and keep it nice and compact

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...