Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript help needed...!

    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

  • #2
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    See if this basic example helps:
    Code:
    <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>
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •