Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 09-26-2006, 03:22 PM correct javascript
Average Talker

Posts: 18
Trades: 0
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()">
<htmlption value="0">SELECT</htmlption>
<htmlptions 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()">
<htmlption value="0">SELECT</htmlption>
<htmlptions property="facilityList" name="facilityForm" />
</html:select>
<br></br>
</html:form>

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


</div>
</BODY>
</html:html>
somsahi is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-27-2006, 08:45 AM Re: correct javascript
Kirtan's Avatar
Who Am I?

Posts: 377
Name: Venkat Raj
Location: Salem, South India
Trades: 3
I have changed some of your html cause i am not familiar with that kind of syntax. The following code works both in IE and Firefox. Hope this helps.
Code:
<html>
<head><title>Hi</title>
<script language="javascript">
function toggle(id)
{
    if(id=='region')
    {
        document.getElementById('facility').selectedIndex=0;
    }
    else
    {
        document.getElementById('region').selectedIndex=0;
    }
}
</script>

</HEAD>
<BODY >
<div class="menu" id="menubar">
<!--
<%String name = (String) request.getAttribute("name");
//out.write(name);
%>
-->
<a href="/nation">National Audit Report</a>
<br></br>
<h1 style="font-size:12px">Regional Audit Report</h1>
<!-- <html:link action="/regionalauditreports">Regional Audit Report</html:link>
<<br></br>-->
<form action="/regionalauditreports">
Region: <select id="region" name="regionForm" onChange="toggle('region')">
<option value="0">SELECT</option>
<option property="regionList" name="regionForm">R List</option>
</select>
</form>
<br></br>
<h1 style="font-size:12px">IATA Audit Report</h1>
<!--<html:link action="/iata">IATA Audit Report</html:link>
<br></br>-->

<form action="/iata">
Facility: <select id="facility" name="facilityForm" onChange="toggle('facility')">
<option value="0">SELECT</option>
<option property="facilityList" name="facilityForm">F List</option>
</select>
<br></br>
</form>

<br></br>
<a href="/help.jsp">Help</a>


</div>
</BODY>
</html>
__________________
All the Buddhas of all the ages have been telling you a very simple fact: Be -- don't try to become.
Kirtan is offline
Reply With Quote
View Public Profile Visit Kirtan's homepage!
 
Reply     « Reply to correct javascript
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11802 seconds with 12 queries