PDA

View Full Version : Call a javascript function



melvinoyh
05-26-2006, 04:25 AM
<script language="javascript">

function disable(){
document.getElementById("submit").disabled=true;
}

</script>

<html>
<body>
<%
String flag="view";
if(flag.equals("view"){%>
<script type="text/javascript">
disable();
</script><%
}
%>

<input type="submit" onClick="onSubmit();" id="submit" value="Submit" style="width:85px"/>

</body>
</html>

wanna ask, for example the calling the function code is correct or not?
before call the function, first check the flag is it 'view' or not, if 'view' then only perform the function.

jscheuer1
05-26-2006, 04:37 AM
This is not purely a javascript question however, it has been my experience that it is usually a bad idea to use a reserved word like 'submit' as a name or an id. This tends to confuse some browsers and when it does, will complicate any troubleshooting efforts.

Twey
05-26-2006, 11:50 AM
Yes, that is the correct way to do it.

melvinoyh
05-27-2006, 12:52 AM
i see. thx.