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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

radio array

Status
Not open for further replies.

sramey00

Programmer
Jun 9, 2004
149
US
Got an odd problem here.

i have a radio array generated from server side. it queries for a filename and assigns that to the value of the radio control.
im using vbscript to access the array from the clientside to (as for testing purposes) msgbox the filename (or value) to the screen.
problem: when there is only one file in the array, it displays the file name in the msgbox fine. however, when there is more than 1 file it doesn't execute. i return an error message stating "object doesn't support this property or method. 'document.form1.OpenFile.Value'

Server Side code:
Code:
do until rsFil.EOF
				filname = rsFil("Filename")
				.Write("<tr><td> <a href=""\\dcsqldev\upload\" & filname & """>" & filname & "</a></td>")
				.Write("<td><input NAME=""OpenFile"" id=""OpenFile"" type=""radio"" value=""" & filname & """></td></tr>")
				rsFil.movenext
			loop

client side VB code
Code:
<SCRIPT FOR="OpenFile" EVENT="OnClick" LANGUAGE="VBSCRIPT">
	dim formPath
	msgbox "hello"
	formPath = document.form1.OpenFile.value 'stops here
	msgbox formPath 
</SCRIPT>

would it be better off in jscript? im not understanding what the problem is with returning the selected value.

Steve

everyday something new is learned, hmmm...
 
You need to iterate through the elements of the array. Here's a quick client-side example that will get you going in the right direction.
Code:
<form name="Form1">
<input type="radio" name="OpenFile" value="Filename1" OnClick="CheckValue()">
<input type="radio" name="OpenFile" value="Filename2" OnClick="CheckValue()">
<Script LANGUAGE="VBSCRIPT">
Sub CheckValue()
for i = 0 to Document.Form1.Elements.length -1
	If Document.Form1.Elements(i).Name = "OpenFile" Then
		If Document.Form1.Elements(i).Checked then
			Alert(Document.Form1.Elements(i).value)
			Exit For
		End IF
	End IF
Next
End Sub
</script>
</form>
 
i've entered your code into my program, however an error is being generated at the line "if document.form1.elements(i).checked then"

the error is invalid character at ln # chr#. Ive searched the internet and found code similar to yours.
do you think the problem is because the radio button is generated from the server side?

Mr. Steve

 
figured it out.

im using
Code:
sub CheckValue()
		msgbox document.Form1.elements.length
		for i = 0 to document.Form1.elements.length - 1
			if document.Form1.elements(i).checked then
				msgbox document.Form1.elements(i).value
				exit for
			end if
		next 
	end sub

i took out the line
if document...name = "Openfile" then

guess the error was generating off that. Most likely if i add more elements to this form then ill have to put that in the error checking. Thanks for the help!

Mr. Steve

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top