textarea naming conundrum - working with php and javascript -


i have form multiple inputs. 1 of inputs text area. here beginning of opening tag:

<textarea id="edit-about-me-input" class="edit-website-input" type="text" name="edit-profile[byc_about_me]"... 

as can see, have chosen name array, that, when post form, have 1 array of values deal with.

however running problem when trying run javascript function on name.

here rest of text area's declaration:

onkeydown="limittext(this.form.edit-profile[byc_about_me],this.form.countdown,1000);"  onkeyup="limittext(this.form.edit-profile[byc_about_me],this.form.countdown,1000);"><?php echo $byc_about_me; ?></textarea> 

obviously, javascript not dashes , brackets. have solution me? can give 2 names or or need rewrite php processes form?

thanks in advance.

simply use square bracket notation instead of dot notation access edit-profile[byc_about_me] property of form object, so:

this.form['edit-profile[byc_about_me]'] 

it's not pretty, works!

related: how reference javascript object property hyphen in it?


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

python - Django-cities exits with "killed" -

python - How to get a widget position inside it's layout in Kivy? -