PDA

View Full Version : Solved: Setting a radio button in IE using VBA



sappunni
06-24-2009, 10:55 AM
The webpage by default has the employee number selected by default. I want to select the SSN using VBA. I noticed that the table name and the radio button
name are one and the same -- table id="eligInquiryForm: PrimaryIdOption" ||| input type="radio" name="eligInquiryForm: PrimaryIdOption"
how do i set the SSN radio button to checked?
I tried ie.document.all.Item("eligInquiryForm: PrimaryIdOption").Value = "SSN" which it did not like.
Thanks and appreciate help !!!!




<form id="eligInquiryForm" method="post" action="/domains/eligibility/eligibility_inquiry.jsf" enctype="application/x-www-form-urlencoded" style="margin-top:0">
<TABLE style="margin-left:35px;" border="0">
<TR>
<TD>
<FIELDSET><LEGEND><B>Query Information</B></LEGEND>
<TABLE class="searchTablePadding1px" align="center" border="0">
<TR>
<TD colspan="2"><span id="eligInquiryForm:primaryId">Primary Identifier:</span>
</TD>
</TR>
<TR>
<TD width="10px"></TD>
<TD>


<table>
<tbody>
<tr>
<td><table id="eligInquiryForm:primaryIdOption">
<tr>
<td>
<label for="eligInquiryForm:primaryIdOption"><input type="radio" checked name="eligInquiryForm:primaryIdOption" value="Employee Number">Employee Number</label></td>
<td>
<label for="eligInquiryForm:primaryIdOption"><input type="radio" name="eligInquiryForm:primaryIdOption" value="SSN">SSN</label></td>
</tr>
</table></td>
<td><input id="eligInquiryForm:primaryIdValue" type="text" name="eligInquiryForm:primaryIdValue" value="1234567890" maxlength="12" size="15" style="margin-left:15px" /></td>
<td></td>
</tr>
</tbody>
</table>

sappunni
06-25-2009, 07:57 AM
I finally figured it out.

Since the tablename and the radio button had the same name I did this



itemlength = ie.document.all.Item("eligInquiryForm:PrimaryIdOption").length


which gave me the length of 3. Then I tried to address the 3 item the first (0) being the table and second (1) is the default and the third (2) was the radio button I wanted to check.



ie.document.all.Item("eligInquiryForm:PrimaryIdOption").Item(2).Checked = True


Thanks