php/javascript help
| From: | B. Keith Murphy | Date: | Tue, 11 Jul 2000 08:41:08 +0000 |
| Subject: | php/javascript help | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-5882@lists.php.net to get a copy of this message | ||
OK, I almost have a project done, but I am running into a little problem. I need to have a box pop
up when the user hits a form button. It should tell how many characters are in the text box. It
seems like a simple problem, but I know nothing about javascript. I don't have a clue as to
how to pass the variable from the php into the javascript either. For completeness sake I have
included the code I currently have. Just as a note, the form dynammically generates a number of
entry boxes depending on a count that the user specifies on the previous page. The javascript needs
to access the array sequence[] Also, as currently coded it doesn't run. I don't know how
to include the javascript so it bombs out when it hits the javascript.
Thanks for any help.
Keith
<? file://orderform.php3
?>
<script language=javascript
function generatelength(str) {
var mylength = 0;
if (!str) return;
else {
mylength = str.length;
alert("The lenght of your sequence is: "+mylenght);
}
return;
}
</script>
<form action="mailto.php3" method="post">
<table border="0">
<? for ($i = 1; $i <= $number_of_oligos; $i++): ?>
<tr>
<td> <? echo ("sequence $i") ?> </td>
<td> <input type="text"
name="sequence[]"><br><br> </td>
<td> <input type="button" name="length" value="How long is
my sequence?" onClick="generateLength()" <br><br></td>
</tr>
<? endfor ?>
<tr>
<td><input type=submit>
</tr>
</table>
</form>