1

I am trying to submit a form using javascript . But its always error out as "Cannot call method submit of undefined " i crosschecked on the name on the form but it didnot worked , I wrote one sample HTML to just check if this approach works and it was working fine . Please help me out on this .

my JSP :

<div id="Symptoms" style="display:none;">
<html:form id="ashutosh" method="POST" action="symptoms" >
<p></p>
<p>Enter/Choose ailment : 

<html:select id="diselc" name="AuthoringForm" property="disease_name" size="1" onchange="javascript:formsubmit(this.formName);" >
<option selected="selected"> </option>
<option>Malaria</option>
<option>High Fever</option>
<option>Cholera</option>
<option>Diarrhoea</option>
</html:select></p>
<p>Choose ailment classification : 
<html:select id="diselchild" name="AuthoringForm" property="diesclassifiaction" > 
<option>High</option>
<option>Medium</option>
<option>Low</option> 
</html:select> 



<fieldset style="width: 381px; height: 126px; padding: 2">
<legend align="left"></legend>
 Tick off patient context :
<html:radio value="Men" name="AuthoringForm" property="patient_context" disabled="false"/>
Men
<html:radio value="Womwen" name="AuthoringForm" property="patient_context" disabled="false"/>
Women
<p>
<html:radio value="Child" name="AuthoringForm" property="patient_context" disabled="false"/>
Child
<html:radio value="Al" name="AuthoringForm" property="patient_context" disabled="false"/>
All
</fieldset>
<p>Enter Pre Conditions</p>
<p><html:textarea rows="2" name="AuthoringForm" cols="20" property="patient_precondition" ></html:textarea>
<p>Must Have Symptoms : 
May Have Symptoms :</p>
<p><html:textarea rows="2" name="AuthoringForm" cols="20" property="must_have_symptoms"></html:textarea>
<!-- <input type="submit" value="Submit" name="B2">-->
<html:textarea rows="2" name="AuthoringForm" cols="20" property="may_have_symptoms"></html:textarea>
<input type="submit" value="Submit" name="symptomsButton"><input type="reset" value="Reset" onclick="clear_form_elements(this.form);"></p>
</html:form>
</div>

my javascript :

function formsubmit(value){
alert("i am just above the form submission"+value); 
document.forms["ashutosh"].submit();
alert("i am just after the form submission");
}
0

2 Answers 2

2

Your problem is that you don't have a form called ashutosh. You have a form with an id called ashutosh, so either use:

document.getElementById('ashutosh').submit();

Or change your HTML code to:

<form name="ashutosh" method="POST" action="symptoms" >
Sign up to request clarification or add additional context in comments.

3 Comments

can anyone tell me why doesnot it work with <html:form > tag ??
I have no idea what that tag is about. When I try it, it won't even work on a normal HTML page. Is it JSP-specific or something? Edit: By the code snippets here, I think you just misunderstood. HTML tags don't use the HTML prefix like the JSP tags.
I don't know much about it, sorry. Is the form displaying correctly when you use that library?
0

It should be something like this:

document.ashutosh.submit();

1 Comment

Relying in the browser providing global variables is so 1997... :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.