PDA

View Full Version : Problematic Text!



Softie2k
04-21-2008, 09:44 PM
I've almost completed my code for my Horoscope page, but I am unable to get the actual text to fit into my Textarea.

Can anyone point out what I've done wrong?

It's late and I'm getting tired :(


<html>

<head>
<script type = "text/javascript">

function showChoices() {
var message = "";
var pick1 = document.myForm.month.selectedIndex;
var pick2 = document.myForm.date.selectedIndex;
if (pick1 == 2 && pick2 > 29) {message = "Invalid date"}
else if ((pick1 == 4 || pick1 == 6 || pick1 == 9 || pick1 == 11) && (pick2 > 30)) {message =

"Invalid Date"}
else {
message = myForm.txt1.value = document.myForm.month.options(pick1).value + " " +

document.myForm.date.options(pick2).value;
}
document.myForm.txt1.value = message;
}

var starsign = ""
if (pick1 == 1 && pick2 <= 14) {starsign = "Pisces"}
if (pick1 == 1 && pick2 >= 15) {starsign = "Cancer"}
if (pick1 == 2 && pick2 <= 14) {starsign = "Cancer"}

if (starsign == "Cancer") {
document.getElementById("horror").value = Cancertext;
}

var Cancertext = "Mars is in trine with Uranus in Pisces this week so take extra care when

when walking across six-lane motorways. You will receive an unexpected surprise if you hand

over your credit card or bank details in response to an email."

</script>
</head>
<body>
<form name = "myForm">
<select name = "month">
<option value = "ChooseMth">Select the month</option>
<option value = "January">January</option>
<option value = "February">February</option>
<option value = "March">March</option>
<option value = "April">April</option>
<option value = "May">May</option>
<option value = "June">June</option>
<option value = "July">July</option>
<option value = "August">August</option>
<option value = "September">September</option>
<option value = "October">October</option>
<option value = "November">November</option>
<option value = "December">December</option>
</select>

<select name = "date">
<option value = "ChooseDate">Select the Date</option>
<option value = "1st">1</option>
<option value = "2nd">2</option>
<option value = "3rd">3</option>
<option value = "4th">4</option>
<option value = "5th">5</option>
<option value = "6th">6</option>
<option value = "7th">7</option>
<option value = "8th">8</option>
<option value = "9th">9</option>
<option value = "10th">10</option>
<option value = "11th">11</option>
<option value = "12th">12</option>
<option value = "13th">13</option>
<option value = "14th">14</option>
<option value = "15th">15</option>
<option value = "16th">16</option>
<option value = "17th">17</option>
<option value = "18th">18</option>
<option value = "19th">19</option>
<option value = "20th">20</option>
<option value = "21st">21</option>
<option value = "22nd">22</option>
<option value = "23rd">23</option>
<option value = "24th">24</option>
<option value = "25th">25</option>
<option value = "26th">26</option>
<option value = "27th">27</option>
<option value = "28th">28</option>
<option value = "29th">29</option>
<option value = "30th">30</option>
<option value = "31st">31</option>
</select>

<input type = "button" name = "show" value = "Show Choices" onclick = "showChoices()" >
<input type = "button" name = "rset" value = "Reset The Form" onclick = "myForm.reset()">
<br><br><br><br>
<input type = "text" name = "txt1">

<textarea name = "horror" id = "horror" rows = "6" cols = "60">
</textarea>
</form>
</body>

</html>



Please help!

Nile
04-21-2008, 09:50 PM
Try this:


<html>

<head>
<script type = "text/javascript">

function showChoices() {
var message = "";
var pick1 = document.myForm.month.selectedIndex;
var pick2 = document.myForm.date.selectedIndex;
if (pick1 == 2 && pick2 > 29) {message = "Invalid date";
}
else if ((pick1 == 4 || pick1 == 6 || pick1 == 9 || pick1 == 11) && (pick2 > 30)) {message ="Invalid Date";
}
else {
message = myForm.txt1.value = document.myForm.month.options(pick1).value;

document.myForm.date.options(pick2).value;
}
document.myForm.txt1.value = message;
}

var starsign = "";
if (pick1 == 1 && pick2 <= 14) {starsign = "Pisces";}
if (pick1 == 1 && pick2 >= 15) {starsign = "Cancer";}
if (pick1 == 2 && pick2 <= 14) {starsign = "Cancer";}

var Cancertext = "Mars is in trine with Uranus in Pisces this week so take extra care when

when walking across six-lane motorways. You will receive an unexpected surprise if you hand

over your credit card or bank details in response to an email.";
if (starsign == "Cancer") {
document.getElementById("horror").value = Cancertext;
}

</script>
</head>
<body>
<form name = "myForm">
<select name = "month">
<option value = "ChooseMth">Select the month</option>
<option value = "January">January</option>
<option value = "February">February</option>
<option value = "March">March</option>
<option value = "April">April</option>
<option value = "May">May</option>
<option value = "June">June</option>
<option value = "July">July</option>
<option value = "August">August</option>
<option value = "September">September</option>
<option value = "October">October</option>
<option value = "November">November</option>
<option value = "December">December</option>
</select>

<select name = "date">
<option value = "ChooseDate">Select the Date</option>
<option value = "1st">1</option>
<option value = "2nd">2</option>
<option value = "3rd">3</option>
<option value = "4th">4</option>
<option value = "5th">5</option>
<option value = "6th">6</option>
<option value = "7th">7</option>
<option value = "8th">8</option>
<option value = "9th">9</option>
<option value = "10th">10</option>
<option value = "11th">11</option>
<option value = "12th">12</option>
<option value = "13th">13</option>
<option value = "14th">14</option>
<option value = "15th">15</option>
<option value = "16th">16</option>
<option value = "17th">17</option>
<option value = "18th">18</option>
<option value = "19th">19</option>
<option value = "20th">20</option>
<option value = "21st">21</option>
<option value = "22nd">22</option>
<option value = "23rd">23</option>
<option value = "24th">24</option>
<option value = "25th">25</option>
<option value = "26th">26</option>
<option value = "27th">27</option>
<option value = "28th">28</option>
<option value = "29th">29</option>
<option value = "30th">30</option>
<option value = "31st">31</option>
</select>

<input type = "button" name = "show" value = "Show Choices" onclick = "showChoices()" >
<input type = "button" name = "rset" value = "Reset The Form" onclick = "myForm.reset()">
<br><br><br><br>
<input type = "text" name = "txt1">

<textarea name = "horror" id = "horror" rows = "6" cols = "60">
</textarea>
</form>
</body>

</html>

Softie2k
04-21-2008, 10:13 PM
I'm sorry, it doesn't seem to have worked. Did you change the position of the var Cancertext ?

Nile
04-21-2008, 10:30 PM
Yes, I did.

Softie2k
04-21-2008, 10:55 PM
Do you have any other possible remedies? I mean, do I need to include another button to move the Var Cancertext into the Textarea?

Softie2k
04-22-2008, 01:22 PM
Sorry just bumping my thread as I am desperate for a remedy!

Master_script_maker
04-22-2008, 09:01 PM
try this:

<html>

<head>
<script type = "text/javascript">

function showChoices() {
var message = "";
var pick1 = parseInt(document.myForm.month.selectedIndex)==null?1:parseInt(document.myForm.month.selectedIndex);
var pick2 = parseInt(document.myForm.date.selectedIndex)==null?1:parseInt(document.myForm.date.selectedIndex);
if (pick1 == 2 && pick2 > 29) {
message = "Invalid date";
}
else if ((pick1 == 4 || pick1 == 6 || pick1 == 9 || pick1 == 11) && (pick2 > 30)) {
message ="Invalid Date";
} else {
message = document.myForm.txt1.value + document.myForm.month.options(pick1).value + " " + document.myForm.date.options(pick2).value;
}
document.myForm.txt1.value = message;
}
function display_msg() {
var starsign = "";
if (pick1 == 1 && pick2 <= 14) {
starsign = "Pisces";
}
if (pick1 == 1 && pick2 >= 15) {
starsign = "Cancer";
}
if (pick1 == 2 && pick2 <= 14) {
starsign = "Cancer";
}
var Cancertext = "Mars is in trine with Uranus in Pisces this week so take extra care when walking across six-lane motorways. You will receive an unexpected surprise if you hand over your credit card or bank details in response to an email.";
if (starsign == "Cancer") {
document.getElementById("horror").value = Cancertext;
}
}
</script>
</head>
<body>
<form name = "myForm">
<select name = "month">
<option value = "ChooseMth">Select the month</option>
<option value = "January">January</option>
<option value = "February">February</option>
<option value = "March">March</option>
<option value = "April">April</option>
<option value = "May">May</option>
<option value = "June">June</option>
<option value = "July">July</option>
<option value = "August">August</option>
<option value = "September">September</option>
<option value = "October">October</option>
<option value = "November">November</option>
<option value = "December">December</option>
</select>

<select name = "date">
<option value = "ChooseDate">Select the Date</option>
<option value = "1st">1</option>
<option value = "2nd">2</option>
<option value = "3rd">3</option>
<option value = "4th">4</option>
<option value = "5th">5</option>
<option value = "6th">6</option>
<option value = "7th">7</option>
<option value = "8th">8</option>
<option value = "9th">9</option>
<option value = "10th">10</option>
<option value = "11th">11</option>
<option value = "12th">12</option>
<option value = "13th">13</option>
<option value = "14th">14</option>
<option value = "15th">15</option>
<option value = "16th">16</option>
<option value = "17th">17</option>
<option value = "18th">18</option>
<option value = "19th">19</option>
<option value = "20th">20</option>
<option value = "21st">21</option>
<option value = "22nd">22</option>
<option value = "23rd">23</option>
<option value = "24th">24</option>
<option value = "25th">25</option>
<option value = "26th">26</option>
<option value = "27th">27</option>
<option value = "28th">28</option>
<option value = "29th">29</option>
<option value = "30th">30</option>
<option value = "31st">31</option>
</select>

<input type = "button" name = "show" value = "Show Choices" onclick = "showChoices()" >
<input type = "button" name = "rset" value = "Reset The Form" onclick = "myForm.reset()">
<br><br><br><br>
<input type = "text" name = "txt1">

<textarea name = "horror" id = "horror" rows = "6" cols = "60">
</textarea>
</form>
</body>

</html>