accessing div tag problem

Results 1 to 3 of 3

Thread: accessing div tag problem

  1. #1
    Join Date
    Dec 1969

    Default accessing div tag problem

    i would like to know how to access a div tag inside a form.. basically<BR><BR>&#060;form name="test"&#062;<BR>&#060;div id="x"&#062; <BR>&#060;select name="something"&#062;<BR> &#060;option value="1"&#062;test<BR> &#060;/select&#062;<BR>&#060;/div&#062;<BR>&#060;/form&#062;<BR>now how would i be able to access that ..<BR>i have a feeling that it is not possible.. but if it is possible would anyone be able to help? or suggest another way?

  2. #2
    Join Date
    Dec 1969

    Default Browser dependent...

    With MSIE<BR> theDiv = document.all["x"];<BR><BR>With NS<BR> theDiv = document.layers["x"];<BR><BR>But after you *have* the ref to the DIV, then what you can do with it is very, very different between MSIE and NS 4.<BR><BR>Check out:<BR><BR>especially chapter 12.<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: accessing div tag problem

    This code only works with NN and IE 5+ but you can use javascript:<BR><BR>&#060;script&#062;<BR>function gettag()<BR>{<BR> var div_element = document.getElementById("x");<BR> // do something with it e.g change font colour<BR> = "red"<BR>}<BR>&#060;/script&#062;<BR>you can use getElemetnById(id) to access nearly any element within a page as long as the id="x" attribute is set. Hope this helps

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts