control name as variable

L

led

window.document.fp1.variable.disabled=true

it is possible to write the name of a form control using a variable in a
expressio like that???

thanks
 
D

David Berry

Did you define the variable first? Ex:

var variable = 'X';

Can you give us a little more information about what you're trying to do?
Are you trying to reference an object on a form? Ex:

document.FORMNAME.FIELDNAME.value

Where you have disable = true. are you trying to disable a field or button
on a form? Ex:

document.FORMNAME.OBJECTNAME.disabled= true or
document.FORMNAME.OBJECTNAME.readOnly = true

Please provide more information
 
L

led

yes i try to work on a field in a form and the object name is passed in a
procedure parameter..
 
D

David Berry

How are you passing the name of the object? What's the whole code or a URL
where we can see this?
 
J

Jon Spivey

Not like that, like this

document.forms['YourForm'].elements[VariableName].disabled=true;

Cheers,
Jon
 
L

led

and in vbscript



Jon Spivey said:
Not like that, like this

document.forms['YourForm'].elements[VariableName].disabled=true;

Cheers,
Jon

led said:
window.document.fp1.variable.disabled=true

it is possible to write the name of a form control using a variable in a
expressio like that???

thanks
 
D

David Berry

You mean with ASP? Either

var VariableName = <%=VariableName%>;
document.forms['YourForm'].elements[VariableName].disabled=true;

Or

document.forms['YourForm'].elements[<%=VariableName%>].disabled=true;

In either case, somewhere on the page you have to define what's being held
in VariableName or the value will be blank. Ex:

<%
VariableName = Request.Form("FieldName")
%>


led said:
and in vbscript



Jon Spivey said:
Not like that, like this

document.forms['YourForm'].elements[VariableName].disabled=true;

Cheers,
Jon

led said:
window.document.fp1.variable.disabled=true

it is possible to write the name of a form control using a variable in a
expressio like that???

thanks
 
Top