wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes sbmission of form through javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "sbmission of form through javascript" Watch "sbmission of form through javascript" New topic
Author

sbmission of form through javascript

arjun rampal
Ranch Hand

Joined: Jul 08, 2005
Posts: 125
Hi expected functionality -
I have two drop down .when value in one drop down is chosen other should show select and when value is chosen in second first one should automatically switch to select.
so to get this i have used following javascript.

present functionality-as soon as value from one dropdown the other swtiches to select just for moment then it takes previous value.the select should be stable not for seconds

<script language="javascript">
function submitRegion()
{

document.facilityForm.facility.selectedIndex = "0";
var ind = document.regionForm.region.selectedIndex;

if ( ind == 0)
{
alert('Please select the required region ..');
return;
}
else
{
document.regionForm.submit();
}
}
</script>

<script language="javascript">
function submitFacility()
{document.regionForm.region.selectedIndex = "0";


var ind = document.facilityForm.facility.selectedIndex;

if ( ind == 0)
{
alert('Please select the required facility ..');
return;
}
else
{
document.facilityForm.submit();
}
}
</script>




</HEAD>

<BODY >
<div class="menu" id="menubar">
<!--
<%String name = (String) request.getAttribute("name");
//out.write(name);
%>
-->

<html:link action="/nation">National Audit Report</html:link>
<br></br>

<h1 style="font-size:12px">Regional Audit Report</h1>
<!-- <html:link action="/regionalauditreports">Regional Audit Report</html:link>
<<br></br>-->
<html:form action="/regionalauditreports">
Region: <html:select style="width:95px;" property="region" name="regionForm" size="1" onchange="submitRegion()">
<html ption value="0">SELECT</html ption>
<html ptions property="regionList" name="regionForm" />

</html:select>
</html:form>
<br></br>
<h1 style="font-size:12px">IATA Audit Report</h1>
<!--<html:link action="/iata">IATA Audit Report</html:link>
<br></br>-->

<html:form action="/iata">
Facility: <html:select property="facility" name="facilityForm" size="1" onchange="submitFacility()">
<html ption value="0">SELECT</html ption>
<html ptions property="facilityList" name="facilityForm" />
</html:select>
<br></br>
</html:form>

<br></br>
<html:link page="/help.jsp">Help</html:link>



</div>

</BODY>
</html:html>
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
well one thing is selectedIndex is a number value and not a string value like you are setting.

Now I do not understand what your issue is exactly. What is not happening correctly? I do not understand what your last statement meant about stable.

Eric
arjun rampal
Ranch Hand

Joined: Jul 08, 2005
Posts: 125
Hi

I have two drop down for facility and region.
Now I am giving first option as select in both drop down.

Initial In both dropdown select,select
now whn i choose region it should show data for region .
now when i choose the dropdown from facility region,region dropdown which wa previously selected should automatically go to select.
in presnt code it is going to selecte but only for seconds after that it takes the previous values
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You mean after the page posts back after the form submission, it is going back to the orginal value?

If that is the case you probably need to set the value from the serverside.

Eric
arjun rampal
Ranch Hand

Joined: Jul 08, 2005
Posts: 125
no not to original value to the first option that is select
please see the code .select is the only code which is not coming from form
it would be great help if i could get solution as soon as possible

is there any possiblity i can attach screenshot with this thread
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sbmission of form through javascript
 
Similar Threads
javascript function
submission
submission problem
value submit html:select
form submission