Jump to content

[SOLVED] Help me on dis topic


dimple

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/176800-solved-help-me-on-dis-topic/
Share on other sites

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.

<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>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.