Jump to content

[SOLVED] if you have specific field name


ted_chou12

Recommended Posts

It's not a good practice to name variable like this

 

if its a delete button then you should name it as - btnDelete

if some Variable is there then it should be - varName

 

do u get some error if you use document.photocomment.delete.style.visibility ... something like this ?

It's not a good practice to name variable like this

 

if its a delete button then you should name it as - btnDelete

if some Variable is there then it should be - varName

 

Hmm that's kinda what my Visual Basic tutor taught me at college, but to be honest I don't follow it. I find it a much bigger ball ache than it's worth; meaningful variable names should avoid any confusion. As for 'delete', I don't even think it's a prototype is it? What errors do you get?

 

EDIT: I've found a 'delete operator'; but that uses a different syntax so shouldn't cause any problems...

Ok, I am in TOTAL agreement with those above - do not name elements "delete" or anything else that would cause a conflict. But, just for educational purposes, there is a workaround.

 

document.photocomment['delete'].style.visibility = ...

 

I only pose this because if you have fields named so they will be processed as arrays (i.e. name="foo[]") then you need to use this method to reference the fields.

 

var fieldsArrayObj = document.formName['foo[]'];

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.