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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.