Getting the id/value of a TextBox,Checkbox,Combo

<body>
<form id="form1" name="form1" method="post" action="">
<table width="100%" border="1" id="addCaseLinkTable">
  <tr>
    <td>
        <input type="text" name="firstName"  value="John"/>
    </td>
    <td><label>
      <input type="checkbox" name="checkbox" value="checkbox" />
      checkMenu
      <select name="select">
        <option>one</option>
         <option>two</option>
      </select>
    </label></td>
      <td><button onclick="disablePopulated(0)">click me</button></td>
  </tr>
</table>
 </form>
</body>



Now Consider this JS
<script language="javascript">
function disablePopulated(jcount){
var table = document.getElementById('addCaseLinkTable');       
var totalRows = table.rows.length;

rowElement=table.rows.item(jcount); // gets me the selected row

var valueOfTextBox = rowElement.cells[0].?????????
var valueOfCheckBox = rowElement.cells[1].?????????
var valueOfSelect= rowElement.cells[2].?????????
}
</script>

How do I get the actual values of the 3 items and how do i make them readonly
ie how do I get a reference to textfield , change its value and then make it readonly if needed..

Thanks

ashok_001Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ashok_001Author Commented:
Remember the fields will be in a table/list and there will be multipe checkboxes,input boxes etc bearing the same name
0
Pravin AsarPrincipal Systems EngineerCommented:
<script language="javascript">
function disablePopulated(theForm) {
   var needTypes = ("text,checkbox,select").split(',');
   var needObjs  = new Array();
   var nx=0;
   var elems = theForm.elements;
   for (var ix=0; ix < elems.length; ix++) {
       var curElem = elems[ix];
         if (!curElem || !curElem.type) { continue; }
         for (jx=0; jx < needTypes.length;jx++) {
              if (needTypes[jx].match (curElem.type)) {
                        needObjs[nx++] = curElem;
                  }
                  // Select Requires matching with tagName
              if (needTypes[jx].toUpperCase().match (curElem.tagName)) {
                        needObjs[nx++] = curElem;
                  }
         }
   }
   for (ix=0; ix < needObjs.length; ix++) {
               needObjs[ix].setAttribute ("disabled",true);

         alert ('Form Element ' + needObjs[ix].name + ' Type ' + needObjs[ix].type);
   }
   return (false);
}
</script>

<form id="form1" name="form1" method="post" action="">
<table width="100%" border="1" id="addCaseLinkTable">
  <tr>
    <td>
        <input type="text" name="firstName"  value="John">
    </td>
    <td><label>
      <input type="checkbox" name="checkbox" value="checkbox" />
      checkMenu
      <select name="select">
       <option>one</option>
        <option>two</option>
      </select>
    </label>
      </td>
    <td>
      <button onclick="return disablePopulated(this.form);">click me</button>
    </td>
  </tr>
</table>
</form>
0
ashok_001Author Commented:
This is great !! The only thing though is that I will have multiple rows of the same thing....

eg:
---

  <tr>
    <td>
        <input type="text" name="firstName"  value="John">
    </td>
    <td><label>
      <input type="checkbox" name="checkbox" value="checkbox" />
      checkMenu
      <select name="select">
       <option>one</option>
        <option>two</option>
      </select>
    </label>
     </td>
    <td>
     <button onclick="return disablePopulated(this.form);">click me</button>
    </td>
  </tr>
    <tr>
    <td>
        <input type="text" name="firstName"  value="John">
    </td>
    <td><label>
      <input type="checkbox" name="checkbox" value="checkbox" />
      checkMenu
      <select name="select">
       <option>one</option>
        <option>two</option>
      </select>
    </label>
     </td>
    <td>
     <button onclick="return disablePopulated(this.form);">click me</button>
    </td>
  </tr>


The button will tell me which box/row I clicked
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

ashok_001Author Commented:
any takers for 200 points?
0
Pravin AsarPrincipal Systems EngineerCommented:
I saw your updated request. This needs a completely different approach (instead of walking through forms elements needs a DOM walk through)...
Which can be done. But is a complete rewrite.


0
Pravin AsarPrincipal Systems EngineerCommented:
This one is a rewrite...

<script language="javascript">
function getParent (src, tagName) {
     while (src.parentNode != null) {
          if (src.parentNode.tagName  == tagName) {
               return src.parentNode;
          }
          src = src.parentNode;
     }
     return src;
}

function srchChildNodes (srchObj) {
      var nx=0;
      var needTypes = ("text,checkbox,select").split(',');
      var needObjs  = new Array();
      if (!srchObj) { return; }
      if (!srchObj.childNodes) { return; }
      var elems = srchObj.childNodes;
      for (var ix=0; ix < elems.length; ix++) {
            var curElem = elems[ix];
            if (curElem.childNodes) { srchChildNodes (curElem); }
      
            if (!curElem || !curElem.type) { continue; }
            for (jx=0; jx < needTypes.length;jx++) {
                  if (needTypes[jx].match (curElem.type)) {
                  needObjs[nx++] = curElem;
                  }
                  // Select Requires matching with tagName
                  if (needTypes[jx].toUpperCase().match (curElem.tagName)) {
                        needObjs[nx++] = curElem;
                  }
            }
      }
      for (ix=0; ix < needObjs.length; ix++) {
            needObjs[ix].setAttribute ("disabled",true);
            //alert ('Form Element ' + needObjs[ix].name + ' Type ' + needObjs[ix].type);
      }
}
function disablePopulated(theFld) {
   var srchFld = getParent (theFld, "TR");
   var elems = srchFld.childNodes;
   srchChildNodes (srchFld);
   return false;
}
</script>

<form id="form1" name="form1" method="post" action="">
<table>
<tr>
    <td>
        <input type="text" name="firstName"  value="John">
    </td>
    <td><label>
      <input type="checkbox" name="checkbox" value="checkbox" />
      checkMenu
      <select name="select">
       <option>one</option>
        <option>two</option>
      </select>
    </label>
     </td>
    <td>
     <button onclick="return disablePopulated(this);">click me</button>
    </td>
  </tr>
    <tr>
    <td>
        <input type="text" name="firstName"  value="John">
    </td>
    <td><label>
      <input type="checkbox" name="checkbox" value="checkbox" />
      checkMenu
      <select name="select">
       <option>one</option>
        <option>two</option>
      </select>
    </label>
     </td>
    <td>
     <button onclick="return disablePopulated(this);">click me</button>
    </td>
  </tr>
</table>
</form>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ashok_001Author Commented:
sorry for the late reply. this is super! you are awesome
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.