dimple Posted October 7, 2009 Share Posted October 7, 2009 hi, i have a combo box & 2 text box on my form for example: <form id="form1" name="form1" method="post" action=""> <select name="payment_mode" id="payment_mode"> <option value="cash">Cash</option> <option value="cheque">Cheque</option> <option value="credit card">Credit Card</option> </select> <input type="text" name="cheque no." id="cheque no." /> <input type="text" name="bank_name" id="bank_name" /> Now I want to hide those text box when the selected value from combo is cash. It works with the submit button but i dnt want to use submit button. How to i determine the selected value of list without submission of form. Quote Link to comment Share on other sites More sharing options...
btherl Posted October 7, 2009 Share Posted October 7, 2009 You need to use javascript. If you also require information from the server when an option is selected then you need ajax, but from what you've said, you just need plain javascript. Keep in mind that values can still be submitted even if they are not visible. Quote Link to comment Share on other sites More sharing options...
dimple Posted October 7, 2009 Author Share Posted October 7, 2009 i dnt knw javascript , so can u provide me some code Quote Link to comment Share on other sites More sharing options...
btherl Posted October 7, 2009 Share Posted October 7, 2009 Look for "javascript tutorial" or "javascript hide form elements" and you'll find some guides and sample code, as well as other people asking the same question as you are. Quote Link to comment Share on other sites More sharing options...
dimple Posted October 7, 2009 Author Share Posted October 7, 2009 hey thanx, i found its solution. Quote Link to comment Share on other sites More sharing options...
dimple Posted October 7, 2009 Author Share Posted October 7, 2009 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Untitled Document</title> <!--Make an HTML page and place this script inside the HEAD tag:--> <script language="JavaScript"> function showhidefield() { if (document.frm.chkbox.checked) { document.getElementById("hideablearea").style.visibility = "visible"; } else { document.getElementById("hideablearea").style.visibility = "hidden"; } } </script> </head> <body> <!--Put the following code inside the BODY tag:--> <form name='frm' action=''> <input type="checkbox" name="chkbox" onclick="showhidefield()"> <!-- Check/uncheck here to show/hide the other form fields--> <br> <div id='hideablearea' style='visibility:hidden;'> <input type='text'><br> <input type='submit'> </div> <!-- This is a text line below the hideable form fields.--> <br> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
dimple Posted October 7, 2009 Author Share Posted October 7, 2009 http://www.phpfreaks.com/forums/index.php/topic,118755.0.html Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.