How to call script in jsp

How to call script in jsp

3A-_@. Feb 8, 2007 3:08 AM

Hi,

I have abc.jsp file where i want to call javascript on pressing submit button.

<input type="text" name="UserName" value="" width="30" />

<input type="submit" value="Submit" onclick=" <what should i write here?">

here how to call script?

and in the same abc.jsp file i have javascript ( i am not sure about the way i m accessing text value inside javascript is right or not)

<SCRIPT LANGUAGE="javascript" >

here how can i access UserName field value here?

if(isThisNotNull(UserName))

alert("UserName Is Mandatory");

</SCRIPT>

[688 byte] By [3A-_@.a] at [2007-11-26 17:45:55]
# 1
you write your condition test inside a function and you call that function as onclick="function_name();"
my.doubtsa at 2007-7-9 0:14:04 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
if(document.formName.UserName.value==null)orif(document.forms[0].UserName.value==null)
java_usera at 2007-7-9 0:14:04 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
what are you trying to ask pl be specific.if declaration then the first one should only be used
my.doubtsa at 2007-7-9 0:14:04 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
I wanted to know both 1) how to call script from jsp page and 2) how to access jsp variable inside the ScriptThanks both of you :)
3A-_@.a at 2007-7-9 0:14:04 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
Answer for 1 onClick="javascriptfunctionname();" Andand to acces value from the JSP in script var strFname = document.getElementById('UserName').value;I think u r looking for thisMessage was edited by: Greeks
Greeksa at 2007-7-9 0:14:04 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...