What is a use of document.getElementById('header_attachment_list_label');

DS20
Tera Contributor

Hi,

  I found "var attachments = document.getElementById('header_attachment_list_label');
if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none') " used in the onSubmit Catalog client script.

 why below elements are used:-

1.document.getElementById()?

2.From where "header_attachment_list_label" id is getting?

Is any alternative to document.getElementById() method.

 

Thanks in advanced.

1 ACCEPTED SOLUTION

Omkar Mone
Mega Sage

Hi 

1) document.getElementById() is a DOM manipulation method to get the element from HTML code with the Id. As id for every element is different it can be used to get that particular element by it's ID (more like a unique key).

2) When you go to a particular page, press f12 there you'll see the html page in console with id's from there it is taken

3) You can use g_form too.

 

Mark correct if it helps.

 

Regards,

Omkar Mone

www.dxsherpa.com

View solution in original post

6 REPLIES 6

keyurmishra
Kilo Contributor

Hi,

The easiest way to access a single element in the DOM is by its unique ID. We can grab an element by ID with the getElementById() method of thedocument object. document.getElementById(); In order to be accessed by ID, the HTML element must have an id attribute.

Regards,

Keyur

 

 

Please Hit Correct(If it is a correct solution) or Hit Helpful(If it is useful). 

Omkar Mone
Mega Sage

Hi 

1) document.getElementById() is a DOM manipulation method to get the element from HTML code with the Id. As id for every element is different it can be used to get that particular element by it's ID (more like a unique key).

2) When you go to a particular page, press f12 there you'll see the html page in console with id's from there it is taken

3) You can use g_form too.

 

Mark correct if it helps.

 

Regards,

Omkar Mone

www.dxsherpa.com

DS20
Tera Contributor

3)which method g_form. should I use in catalog client script to verify the attachment presence?

Hi 

If the variable is not be accessed from client script so that time you need to use documnet.getElementById();