Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert from Javascript to PHP?

Status
Not open for further replies.

mancroft

Programmer
Joined
Oct 26, 2002
Messages
267
Location
GB
Can either of the two pieces of code below be converted to work in PHP only or will they only work in Javascript?

The first one counts and restricts the number of characters inputted into a textarea and the second one highlights the contents of a text area.

Code:
<textarea name="theDescription" wrap=physical cols=75 rows=3

onKeyUp="textCounter(this.form.theDescription,this.form.remLen3,200);"
onKeyDown="textCounter(this.form.theDescription,this.form.remLen3,200);"
onFocus="textCounter(this.form.theDescription,this.form.remLen3,200);"
></textarea>
<br><input readonly type=text name=remLen3 size=4 maxlength=4 value="200"> description characters left.<Br><Br>


<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}
// End -->
</script>

Second:

Code:
<input type=button value="HIGHLIGHT ALL" onClick="javascript:this.form.output1.focus();this.form.output1.select();" class="input1">
<textarea cols=50 rows=15 wrap="hard" name="output1">

BLAH

</textarea>
 
PHP runs on the server and when the page is served, PHP has done all it's job. Counting the number of inputed characters or highlighting text in a textarea is client-side scripting, i.e. JavaScript. Sorry.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top