LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Bug in Javascript (https://www.linuxquestions.org/questions/programming-9/bug-in-javascript-103518/)

Linh 10-13-2003 03:32 PM

Bug in Javascript
 
When I clicked on the submit button, the alert statement on line number 2 came up as undefined, but on line 34, I had set the value to be "w" as in value=w

34<td align=left border=0 bgcolor=#FE944E width=100%%><input type=radio name=sec_auth value=w size=1>

On line 40, the same radio button is set to "d" as shown below

40<td align=left bgcolor=#FE944E width=100%><input type=radio name=sec_auth value=d size=1>

2 alert (document.form1.sec_auth.value);

on line

4 if (document.form1.sec_auth)
5 alert ("the radio button is highlighted");

The alert did comes up indicating that it did detect the present of a radio button

==============================
Code:

<script LANGUAGE="Javascript">
<!--


function check_if_wg_box_is_blank()
1{
2  alert (document.form1.sec_auth.value);
3
4  if (document.form1.sec_auth)
5    alert ("the radio button is highlighted");
6
7  if (document.form1.sec_auth = "w" && document.form1.wgrp.value == " ")
8    {
9      alert ("the workgroup/domain name field cannot be blank");
10      document.form1.wgrp.focus();
11      document.form1.wgrp.select();
12      return false;
13    }
14  else
15  if (document.form1.sec_auth = "d" && document.form1.lv_pwdsrv.value == " ")
16    {
17      alert ("the domain server name cannot be blank. Default to a *");
18      document.form1.lv_pwdsrv.focus();
19      document.form1.lv_pwdsrv.select();
20      return false;
21    }
22}
23
24
25//-->
26</SCRIPT>

27<table border=0 cellpadding=1 cellspacing=0 align=center bgcolor=#212121 width=99%>
28<form method=post name=form1 onsubmit="return check_if_wg_box_is_blank()" action="<?=$PHP_SELF?>">
29<input type=hidden name=submit value=1>
30<tr>
31
32
33
34<td align=left border=0 bgcolor=#FE944E width=100%%><input type=radio name=sec_auth value=w size=1>
36<font class=black><b>&nbsp;&nbsp;&nbsp;Workgroup</b></font></td>
37
38
39
40<td align=left bgcolor=#FE944E width=100%><input type=radio name=sec_auth value=d size=1>

42<font class=black><b>&nbsp;&nbsp;&nbsp;Windows Domain Server(s)</b></font></td>
43
44<tr><td valign=top><input type=submit name=lb_sec value="Apply Changes to System" class=small></td></tr>


david_ross 10-14-2003 12:38 PM

I may be wrong but I think you need to use:
document.form1.sec_auth.selectIndex.value

If it is a multi value object.


All times are GMT -5. The time now is 01:11 PM.