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

"if" condition based on form submit

Status
Not open for further replies.
Dec 14, 2000
4
0
0
US
I have a function which i want to call on the submit of a form.

e.g.
<form>
some code
<input type=submit name=somename onClick=document.form.action=page2.jsp>

<% if (here i want the code that says implement &quot;if&quot; if the submit button is pressed). I'm trying,

if(request.getParameter(somename).equalsIgnoreCase(submit){}

but it implements the if on page load and gives a null pointer exception.

Thanks in advance for your help
 
> if(request.getParameter(somename).equalsIgnoreCase(submit){}

request.getParameter(&quot;hello&quot;)

That will return 'null' if 'somename' doesnot exist therefore you end up with

null.equalsIgnoreCase(submit)

hence the null pointer exception

Good luck
-pete
 
pete got it right::
but start your page with
<%if (null.equalsIgnoreCase(submit)){
%>
show your form

<%} else {
//handle your code

}%>





 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top