...

View Full Version : Javascript help needed...!



shariff
07-03-2008, 04:56 AM
Good day to everyone,

I have designed a request form where I have three option buttons:

1. Service Request
2. Product Request
3. Both

By default service request is enabled, on selection of product request it have to show the field of product request form and on selecting both option button both the form should be available and vise versa.

Since I have started learning I would request your help or any source where I can build this kind of forms.

Your comments and queries of the above will highly appreciated.

Regards

rangana
07-03-2008, 05:25 AM
See if this basic example helps:


<script type="text/javascript">
window.onload=function()
{
var sr=document.getElementById('sr'), // get the ID of the Service Request button
pr=document.getElementById('pr'), // get the ID of the Product Request button
both=document.getElementById('both'), // get the ID of Both button
service_req=document.getElementById('service_req'),
// get the ID of the element (div) that holds Service Requests's content
product_req=document.getElementById('product_req') ;
// get the ID of the element (div) that holds Product Requests's content
sr.onclick=function(){reset();service_req.style.display='';}
pr.onclick=function(){reset();product_req.style.display='';}
both.onclick=function(){reset();service_req.style.display='';
product_req.style.display='';}
reset();
}
function reset()
{
service_req=document.getElementById('service_req'),
// get the ID of the element (div) that holds Service Requests's content
product_req=document.getElementById('product_req') ;
// get the ID of the element (div) that holds Product Requests's content
service_req.style.display='none';
product_req.style.display='none';
}
</script>
<input type="button" value="Service Request" id="sr">
<input type="button" value="Product Request" id="pr">
<input type="button" value="Both" id="both">
<div id="service_req">
<h1>Service Request</h1>
Contents Here. All the elements you wish which includes form.
</div>
<div id="product_req">
<h1>Product Request</h1>
Contents Here. All the elements you wish which includes form.
</div>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum