Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

want only one textarea open

Posted on 2010-09-03
16
Medium Priority
?
287 Views
Last Modified: 2012-06-22
want only one textarea open


this change doesnt work

onchange="if(this.value.indexOf('Wed')==0){ document.getElementById('textareaID2').style.display='block';
document.getElementById('textareaID').style.display='none';}
 else{ document.getElementById('textareaID2').style.display='none';}"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form method=post action=pb-dropck.php>
<select name=t1 onchange="if(this.value.indexOf('Tue')==0) document.getElementById('textareaID').style.display='block'; else document.getElementById('textareaID').style.display='none';">
<option value=Mon $Mon>Mon</option>
<option value=Tue $Tue>Tue</option>
<option value=Wed $Wed>Wed</option>
<option value=Thu $Thu>Thu</option>
<option value=Fri $Fri>Fri</option>
<option value=Sat $Sat>Sat</option>
<option value=Sun $Sun>Sun</option>
</select>

<select name=t2 onchange="if(this.value.indexOf('Wed')==0) document.getElementById('textareaID2').style.display='block'; else document.getElementById('textareaID2').style.display='none';">
<option value=Mon $Mon>Mon</option>
<option value=Tue $Tue>Tue</option>
<option value=Wed $Wed>Wed</option>
<option value=Thu $Thu>Thu</option>
<option value=Fri $Fri>Fri</option>
<option value=Sat $Sat>Sat</option>
<option value=Sun $Sun>Sun</option>
</select>
<input type=submit value=Submit>
<textarea id="textareaID" cols="20" rows="20" style="display:none"></textarea>
<textarea id="textareaID2" cols="20" rows="20" style="display:none"></textarea>
</form>
</body>
</html>

Open in new window

0
Comment
Question by:rgb192
[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
  • 7
  • 5
  • 2
  • +2
16 Comments
 

Expert Comment

by:spamzerozone
ID: 33597725
In html
<textarea></textarea>

Dont know about php sorry.
0
 
LVL 13

Expert Comment

by:ansudhindra
ID: 33597768
onchange="if(this.value.indexOf('Wed')==0){ document.getElementById('textareaID2').style.display='block';
document.getElementById('textareaID').style.display='none';}
 else{ document.getElementById('textareaID2').style.display='none';document.getElementById('textareaID').style.display='block';}"


will this work or you are looking for something else?
0
 
LVL 11

Expert Comment

by:Rajesh Dalmia
ID: 33597769
in onchange what indexOf('Tue') and indexOf('Wed') means?
I think in indexOf it should be the id of the select box...
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 13

Expert Comment

by:ansudhindra
ID: 33597805
May be attached file may help you.
textarea-test.html
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33598554
Check this :


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form method=post action=pb-dropck.php>

<select name=t1 onchange="if(this.value.indexOf('Tue')==0){document.getElementById('textareaID2').style.display='none';document.getElementById('textareaID').style.display='block';}else{document.getElementById('textareaID2').style.display='block';document.getElementById('textareaID').style.display='none';}">
    <option value=Mon $Mon>Mon</option>
    <option value=Tue $Tue>Tue</option>
    <option value=Wed $Wed>Wed</option>
    <option value=Thu $Thu>Thu</option>
    <option value=Fri $Fri>Fri</option>
    <option value=Sat $Sat>Sat</option>
    <option value=Sun $Sun>Sun</option>
</select>

<select name=t2 onchange="if(this.value.indexOf('Wed')==0){document.getElementById('textareaID').style.display='none';document.getElementById('textareaID2').style.display='block';}else{document.getElementById('textareaID').style.display='block';document.getElementById('textareaID2').style.display='none';}">
    <option value=Mon $Mon>Mon</option>
    <option value=Tue $Tue>Tue</option>
    <option value=Wed $Wed>Wed</option>
    <option value=Thu $Thu>Thu</option>
    <option value=Fri $Fri>Fri</option>
    <option value=Sat $Sat>Sat</option>
    <option value=Sun $Sun>Sun</option>
</select>

<input type=submit value=Submit>
<textarea id="textareaID" cols="20" rows="20" style="display:none"></textarea>
<textarea id="textareaID2" cols="20" rows="20" style="display:none"></textarea>

</form>
</body>
</html>

Open in new window

0
 
LVL 82

Expert Comment

by:leakim971
ID: 33598565
This too :


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form method=post action=pb-dropck.php>

<input type="radio" value="Mon" name="t1" />Mon<br />
<input type="radio" value="Tue" name="t1" onclick="if(this.checked) {document.getElementById('textareaID').style.display='block';document.getElementById('textareaID2').style.display='none';}" />Tue<br />
<input type="radio" value="Wed" name="t1" onclick="if(this.checked) {document.getElementById('textareaID2').style.display='block';document.getElementById('textareaID').style.display='none';}" />Wed<br />
<input type="radio" value="Thu" name="t1" />Thu<br />
<input type="radio" value="Fri" name="t1" />Fri<br />
<input type="radio" value="Sat" name="t1" />Sat<br />
<input type="radio" value="Sun" name="t1" />Sun<br />
<input type="submit" value="Submit" />
<textarea id="textareaID" cols="20" rows="20" style="display:none">1</textarea>
<textarea id="textareaID2" cols="20" rows="20" style="display:none">2</textarea>

</form>
</body>
</html>

Open in new window

0
 

Author Comment

by:rgb192
ID: 33612678
the textarea does not disappear if
neither
tue or wed is selected
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form method=post action=pb-dropck.php>

<select name=t1 onchange="if(this.value.indexOf('Tue')==0){document.getElementById('textareaID2').style.display='none';document.getElementById('textareaID').style.display='block';}else{document.getElementById('textareaID2').style.display='block';document.getElementById('textareaID').style.display='none';}">
    <option value=Mon $Mon>Mon</option>
    <option value=Tue $Tue>Tue</option>
    <option value=Wed $Wed>Wed</option>
    <option value=Thu $Thu>Thu</option>
    <option value=Fri $Fri>Fri</option>
    <option value=Sat $Sat>Sat</option>
    <option value=Sun $Sun>Sun</option>
</select>

<select name=t2 onchange="if(this.value.indexOf('Wed')==0){document.getElementById('textareaID').style.display='none';document.getElementById('textareaID2').style.display='block';}else{document.getElementById('textareaID').style.display='block';document.getElementById('textareaID2').style.display='none';}">
    <option value=Mon $Mon>Mon</option>
    <option value=Tue $Tue>Tue</option>
    <option value=Wed $Wed>Wed</option>
    <option value=Thu $Thu>Thu</option>
    <option value=Fri $Fri>Fri</option>
    <option value=Sat $Sat>Sat</option>
    <option value=Sun $Sun>Sun</option>
</select>

<input type=submit value=Submit>
<textarea id="textareaID" cols="20" rows="20" style="display:none"></textarea>
<textarea id="textareaID2" cols="20" rows="20" style="display:none"></textarea>

</form>
</body>
</html>

Open in new window

0
 
LVL 82

Expert Comment

by:leakim971
ID: 33612842
Check this :


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form method=post action=pb-dropck.php>

<select name=t1 onchange="function $(o){return document.getElementById(o);};$('textareaID').style.display='none';$('textareaID2').style.display='none';var _s=this.value.substr(0,3).toLowerCase();switch(_s){case 'tue':$('textareaID').style.display='block';break;case 'wed':$('textareaID2').style.display='block';break;}">
    <option value=Mon $Mon>Mon</option>
    <option value=Tue $Tue>Tue</option>
    <option value=Wed $Wed>Wed</option>
    <option value=Thu $Thu>Thu</option>
    <option value=Fri $Fri>Fri</option>
    <option value=Sat $Sat>Sat</option>
    <option value=Sun $Sun>Sun</option>
</select>

<select name=t2 onchange="function $(o){return document.getElementById(o);};$('textareaID').style.display='none';$('textareaID2').style.display='none';var _s=this.value.substr(0,3).toLowerCase();switch(_s){case 'wed':$('textareaID2').style.display='block';break;case 'tue':$('textareaID').style.display='block';break;}">
    <option value=Mon $Mon>Mon</option>
    <option value=Tue $Tue>Tue</option>
    <option value=Wed $Wed>Wed</option>
    <option value=Thu $Thu>Thu</option>
    <option value=Fri $Fri>Fri</option>
    <option value=Sat $Sat>Sat</option>
    <option value=Sun $Sun>Sun</option>
</select>

<input type=submit value=Submit>
<textarea id="textareaID" cols="20" rows="20" style="display:none"></textarea>
<textarea id="textareaID2" cols="20" rows="20" style="display:none"></textarea>

</form>
</body>
</html>

Open in new window

0
 

Author Comment

by:rgb192
ID: 33612920
I placed a 1 in textarea1 and 2 in textarea2

works
but when I
use select1, textarea2 gets open if I start at tue and go to wed

select1 should only open textarea1
and
select2 should only open textarea2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form method=post action=pb-dropck.php>

<select name=t1 onchange="function $(o){return document.getElementById(o);};$('textareaID').style.display='none';$('textareaID2').style.display='none';var _s=this.value.substr(0,3).toLowerCase();switch(_s){case 'tue':$('textareaID').style.display='block';break;case 'wed':$('textareaID2').style.display='block';break;}">
    <option value=Mon $Mon>Mon</option>
    <option value=Tue $Tue>Tue</option>
    <option value=Wed $Wed>Wed</option>
    <option value=Thu $Thu>Thu</option>
    <option value=Fri $Fri>Fri</option>
    <option value=Sat $Sat>Sat</option>
    <option value=Sun $Sun>Sun</option>
</select>

<select name=t2 onchange="function $(o){return document.getElementById(o);};$('textareaID').style.display='none';$('textareaID2').style.display='none';var _s=this.value.substr(0,3).toLowerCase();switch(_s){case 'wed':$('textareaID2').style.display='block';break;case 'tue':$('textareaID').style.display='block';break;}">
    <option value=Mon $Mon>Mon</option>
    <option value=Tue $Tue>Tue</option>
    <option value=Wed $Wed>Wed</option>
    <option value=Thu $Thu>Thu</option>
    <option value=Fri $Fri>Fri</option>
    <option value=Sat $Sat>Sat</option>
    <option value=Sun $Sun>Sun</option>
</select>

<input type=submit value=Submit>
<textarea id="textareaID" cols="20" rows="20" style="display:none"></textarea>
<textarea id="textareaID2" cols="20" rows="20" style="display:none"></textarea>

</form>
</body>
</html>

Open in new window

0
 
LVL 82

Expert Comment

by:leakim971
ID: 33612937
what happen if textarea2 is open (Wed selected on the second select) and now you select Tue on the first select ?
0
 

Author Comment

by:rgb192
ID: 33612967
select2=wed
textarea2 is open

then
when select1=tue
textarea1 is open

so that part works
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33612969
you can have two calendars open at the same time ?
0
 

Author Comment

by:rgb192
ID: 33612986
2 select menus

only want
1 textarea open at the same time
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 33613031
Sorry for "calendars" my mind was on an other post lol

OK, check this my friend :


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form method=post action=pb-dropck.php>

<select name="t1" id="t1" onchange="function $(o){return document.getElementById(o);};if(this.value.indexOf('Tue')==0) {$('textareaID2').style.display='none';$('textareaID').style.display='block';}else{$('textareaID').style.display='none';if($('t2').options[$('t2').selectedIndex].value.indexOf('Wed')==0) $('textareaID2').style.display='block';else $('textareaID2').style.display='none';}">
    <option value=Mon $Mon>Mon</option>
    <option value=Tue $Tue>Tue</option>
    <option value=Wed $Wed>Wed</option>
    <option value=Thu $Thu>Thu</option>
    <option value=Fri $Fri>Fri</option>
    <option value=Sat $Sat>Sat</option>
    <option value=Sun $Sun>Sun</option>
</select>

<select name="t2" id="t2" onchange="function $(o){return document.getElementById(o);};if(this.value.indexOf('Wed')==0) {$('textareaID').style.display='none';$('textareaID2').style.display='block';}else{$('textareaID2').style.display='none';if($('t1').options[$('t1').selectedIndex].value.indexOf('Tue')==0) $('textareaID').style.display='block';else $('textareaID').style.display='none';}">
    <option value=Mon $Mon>Mon</option>
    <option value=Tue $Tue>Tue</option>
    <option value=Wed $Wed>Wed</option>
    <option value=Thu $Thu>Thu</option>
    <option value=Fri $Fri>Fri</option>
    <option value=Sat $Sat>Sat</option>
    <option value=Sun $Sun>Sun</option>
</select>

<input type=submit value=Submit>
<textarea id="textareaID" cols="20" rows="20" style="display:none"></textarea>
<textarea id="textareaID2" cols="20" rows="20" style="display:none"></textarea>

</form>
</body>
</html>

Open in new window

0
 

Author Closing Comment

by:rgb192
ID: 33711940
thanks, works great
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33713230
You're welcome! Thanks for the points!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

721 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