Solved

want only one textarea open

Posted on 2010-09-03
16
275 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
  • 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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 500 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now