Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

want only one textarea open

Posted on 2010-09-03
16
Medium Priority
?
288 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 13

Expert Comment

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

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 83

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 83

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 83

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 83

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 83

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 83

Expert Comment

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

783 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