Solved

want only one textarea open

Posted on 2010-09-03
16
278 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
object oriented programming comparison 5 55
<? versus <?php 5 37
php call to a non-object 3 34
How do I change the from header when sending a mail 1 18
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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 count occurrences of each item in an array.
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.

895 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

14 Experts available now in Live!

Get 1:1 Help Now