Jump to content

Can't get textarea character counter to work with other javascripts!


daniish

Recommended Posts

Hello,

I am writing a form but am having difficulty getting two javascripts to run together. I can get both of them working on their own but not together (I'm using the latest Firefox browser)! The javascripts are:

A wysiwyg text editor
A textarea character counter

You can see my form here:
[url=http://globexposure.net/openwysiwyg/add_blog_form4.html]http://globexposure.net/openwysiwyg/add_blog_form4.html[/url]

I tried a second method also (it also doesn't work) which you can see here:
[url=http://globexposure.net/openwysiwyg/add_blog_form2.html]http://globexposure.net/openwysiwyg/add_blog_form2.html[/url]

Can anyone tell me why the textarea character counter does not work?


Many thanks

p.s. I posted on a different forum and only got 1 post which said the counter worked but not the WYSIWYG editor (on Safari browser).
Link to comment
Share on other sites

I think it is easiest if i just give you the whole script. May i draw your attention to the 'Label Description:' which is where i am attempting to get both the WYSIWYG editor and character counter to work.


[code]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Add Blog </TITLE>

< script type="text/javascript" >

/***********************************************
* Drop Down Date select script- by JavaScriptKit.com
* This notice MUST stay intact for use
* Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and more
***********************************************/

var monthtext=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec'];

function populatedropdown(dayfield, monthfield, yearfield){
var today=new Date()
var dayfield=document.getElementById(dayfield)
var monthfield=document.getElementById(monthfield)
var yearfield=document.getElementById(yearfield)
for (var i=0; i<31; i++)
dayfield.options[i]=new Option(i+1, i+1)
dayfield.options[today.getDate()]=new Option(today.getDate(), today.getDate(), true, true) //select today's day
for (var m=0; m<12; m++)
monthfield.options[m]=new Option(monthtext[m], monthtext[m])
monthfield.options[today.getMonth()]=new Option(monthtext[today.getMonth()], monthtext[today.getMonth()], true, true) //select today's month
var thisyear=today.getFullYear()
for (var y=0; y<20; y++){
yearfield.options[y]=new Option(thisyear, thisyear)
thisyear+=1
}
yearfield.options[0]=new Option(today.getFullYear(), today.getFullYear(), true, true) //select today's year
}
</ script >
< SCRIPT LANGUAGE="JavaScript" >

<!-- Begin
  var submitcount=0;
  function checkSubmit() {

      if (submitcount == 0)
      {
      submitcount++;
      document.add_blog.submit();
      }
  }


function textCounter(field, countfield, maxlimit) {
  if (field.value.length > maxlimit)
      {field.value = field.value.substring(0, maxlimit);}
      else
      {countfield.value = maxlimit - field.value.length;}
  }
//  End -->
</ script >
</HEAD>

< script language="JavaScript" type="text/javascript" src="wysiwyg.js" ></ script >

<BODY>

So you've just visited some place new and exciting...well blog those experiences right here. <br>
The 'Travel Blog' & 'Associated Link' are not mandatory.<br><br>

< script language="JavaScript" type="text/javascript" src="wysiwyg.js" ></ script >

<form name=add_blog action="insert.php" method="post">

Title: <br><input type="text" size="79" id="title" method="post" name="title"></input> <br><br>

Date: <br>
<select id="daydropdown"></select>

<select id="monthdropdown"></select>
<select id="yeardropdown"></select> <br><br>

Label Description: <br><textarea rows="5" cols="100" id="description" name="description" onKeyDown="textCounter(this.form.description,this.form.remLentext,255);" onKeyUp="textCounter(this.form.description,this.form.remLentext,255);"></textarea>
< script language="JavaScript1.2">generate_wysiwyg('description');</ script >
<br>Characters remaining: <input type=box readonly name=remLentext size=3 value=255 />
<br><br>

Travel Blog: <br><textarea rows="25" cols="100" id="blog" name="blog"></textarea>
< script language="JavaScript1.2" >generate_wysiwyg('blog');</ script >

<br><br>

Latitude: <br><input type="text" size="7" id="lat" name="lat"></input> <br><br>

Longitude: <br><input type="text" size="7" id="lon" name="lon"></input> <br><br>

Associated Link: <br><textarea rows="10" cols="100" id="link" name="link"></textarea>
< script language="JavaScript1.2" >generate_wysiwyg('link');</ script >
<br><br>

Marker: <br><input type="text" size="10" id="marker" name="marker"></input> <br><br>


<INPUT TYPE="button" VALUE="Submit" onclick='' name="submit" />
</form>

< script type="text/javascript" >
//populatedropdown(id_of_day_select, id_of_month_select, id_of_year_select)
window.onload=function(){
populatedropdown("daydropdown", "monthdropdown", "yeardropdown")
}
</ script >

</BODY>
</HTML>
[/code]


Many thanks - i hope you can see a solution!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.