[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Coldfusion: Block certain fields based on input field

Posted on 2007-04-02
6
Medium Priority
?
187 Views
Last Modified: 2013-12-16
I have a form with 7 fields (fields 1 thru 7). If field1=A, fields 2, 3 and 4 should be blocked and fields 5, 6 and 7 can be entered. If field1=B, the other side around, fields 2, 3 and 4 can be entered and fields 5,6 and 7 blocked.

How can I accomplish this in coldfusion?

Thanks.

Errol
0
Comment
Question by:Errol Farro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 10

Accepted Solution

by:
stu215 earned 600 total points
ID: 18839299
Coldfusion is a server side technology therefore it cant make changes dynamically on the client side.

However you can use javascript ( theres also cfscript which is similar to javascript ) ::

<script>
function chkMyField(){
      if (document.form1.radio1[0].checked==true){
            document.form1.txt2.disabled=true;
            document.form1.txt3disabled=true;
            document.form1.txt4disabled=true;
            document.form1.txt5.disabled=false;
            document.form1.txt6.disabled=false;
            document.form1.txt7.disabled=false;
            document.form1.txt5.focus();
      } else if (document.form1.radio1[1].checked==true){
            document.form1.txt2.disabled=false;
            document.form1.txt3.disabled=false;
            document.form1.txt4.disabled=false;
            document.form1.txt5.disabled=true;
            document.form1.txt6.disabled=true;
            document.form1.txt7.disabled=true;
            document.form1.txt2.focus();
      } else {
            document.form1.txt2.disabled=true;
            document.form1.txt3.disabled=true;
            document.form1.txt4.disabled=true;
            document.form1.txt5.disabled=true;
            document.form1.txt6.disabled=true;
            document.form1.txt7.disabled=true;
      }
}
</script>

<body onLoad="chkMyField();">

<form name="form1">
<input type="radio" name="radio1" value="A" onChange="chkMyField();"/>
<input type="radio" name="radio1" value="B" onChange="chkMyField();"/><br />


<input name="txt2" size="10" value="" /><br />
<input name="txt3" size="10" value="" /><br />
<input name="txt4" size="10" value="" /><br />
<input name="txt5" size="10" value="" /><br />
<input name="txt6" size="10" value="" /><br />
<input name="txt7" size="10" value="" /><br />
</form>

</body>
0
 
LVL 5

Expert Comment

by:mihaimm
ID: 18839921
Also remember validate on server side as java script can be easily disabled and you can't do anything about it. In case something is invalid, return to the page with an error message.
0
 

Author Comment

by:Errol Farro
ID: 18843999
I tried your code and it worked fine with the radio button but actually I have a drop down list with 5 values.
If the field is value1 then it should do part 1, else it should do part 2. I don't know scripting very well. How do I do I change the if line ( if (document.form1.radio1[0].checked==true)) to handle a drop down field?

Thanks. Errol
0
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 
LVL 5

Assisted Solution

by:mihaimm
mihaimm earned 400 total points
ID: 18844596
say you have
<select name="select1">......</select>

Then you change the code posted by stu215 in
if (document.form1.select1.selectedIndex == 0){
...
} else if (document.form1.select1.selectedIndex == 1){
...
} else {
....
}
0
 
LVL 10

Expert Comment

by:stu215
ID: 18844682
Hey,

Doh, had a busy morning @ work but yep, what mihaimm put should work for a drop down.

~Stu :-)
0
 

Author Comment

by:Errol Farro
ID: 18844958
Thanks a lot for your help Guys. It's working. Regards. Errol
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When deciding to adopt any help desk solutions many factors should be explored before taking decisions. This will change from business to another but in general there are some kind of rule of thumb. Here are some quick tips: Do we need only ticket…
Geo-targeting is the practice of distributing content based on a person’s location, as best as you can determine it. Let’s look at some ways you could successfully use this tactic. The following tips and case studies could lead to meaningful results.
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question