Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
 <!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <input style="display:none;" id="mb-comment-newpost-title-944252" />
  <input id="txtSwitchport_a" name="q1_a" type="text" value="Author"/>
  <input id="txtSwitchport_b" name="q1_b" type="text" value="quote2"/> 
  <input id="txtSwitchport_c" name="q1_c" type="text" value="quote3"/>
  <input name="_d" type="text" value="quote4"/>
  <input name="q3_e" type="text" value="quote5"/>
  <div id="li" style="width:200px;height:30px;border:1px solid"></div>
  <button onclick="mytest()">test</button>
  
  <script type="text/javascript">
    function mytest()
    {
      alert("hi");
  var inputs = document.getElementsByTagName("input");
  var myinputs ;
    var op = true;
    for (x=0;x<=inputs.length;x++)
    {
      newpost = inputs[x].getAttribute("id");
        if(newpost.indexOf("txtSwitchport_")==0)
        {
         //document.getElementById(newpost).id.focus();
            if(document.getElementById(newpost).value != "")
              {
                alert(document.getElementById(newpost).value);
             op=false;
               
              }
           
           }
      
      }
    alert('asd');
    }
    </script> 
</body>
</html>
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers