Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check the radio button and submit the form ?

Status
Not open for further replies.

crackoo

Programmer
Feb 17, 2011
132
TN
Hi !
I have this form and i would like to check automatically the first radio button and submit the form
So i ask you how can i perform this in vbscript ?
Thanks !
Code:
<form method="post" name="poll_1575" onsubmit="return poll_results_1575('vote','[URL unfurl="true"]http://www.URL.com/poll/popup.php','M','500','290','toolbar=noscrollbars=yes');"[/URL] action="[URL unfurl="true"]http://www.URL.com/poll/popup.php"[/URL] target="M">
<table width="142" border="0" cellspacing="0" cellpadding="0" align="center">
<tr> 
<td><img src="/images/ti-op.gif" width="142" height="25"></td>
  </tr>
<tr align="center">
    <td background="/images/bg-op.gif">
      <table width="100%" border="0" cellspacing="0" cellpadding="3" align="center">
        <tr>
          <td class="blacktxt" align="center" height="40" valign="middle" colspan="2"> :</td>
        </tr>
        <tr align="right" valign="top">
          <td colspan="2">
              <table width="100%" border="0" cellspacing="0" cellpadding="1" align="center">
<tr>
  <td width="85%" class="redtxt">P</td>
   <td width="15%" class="radio"><input class="input2" type="radio" name="option_id" value="1"></td>
 </tr>
 <tr>
  <td width="85%" class="redtxt">C</td>
   <td width="15%" class="radio"><input class="input2" type="radio" name="option_id" value="2"></td>
 </tr>
 <tr>
  <td width="85%" class="redtxt">S</td>
   <td width="15%" class="radio"><input class="input2" type="radio" name="option_id" value="3"></td>
 </tr>
</table>
</form>
 
Yes i mean check the first value of the radio button and submit the form
Thank you for your reply !
 
Personally, I would do this in javascript.

You'll have to add an listener to each html input in order to actively monitor input values. However, this can be ridiculously inefficient. Also, I'm sure you are aware that you html is severly incomplete.

something like this:

Code:
<script language="vbscript">
   sub checkValue()
      set objRadio = document.getElementById("myRadio")
      msgbox objRadio.value
      if (element.value = "1") then
         set objForm = document.getElementById("myForm")
         objForm.submit()
      end if
   end sub
</script>

<form id="myForm" method="post">
   <input type="radio" name="myRadio" value="1" [red]onClick="checkValue()"[/red]>1<br>
   <input type="radio" name="myRadio" value="2" [red]onClick="checkValue()"[/red]>2<br>
   <input type="radio" name="myRadio" value="3" [red]onClick="checkValue()"[/red]>3<br>
</form>

-Geates

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top