Dynamically Change onchange Event by javascript

We come across various time that we need to change the form action according to the Event

Let me provide a simple JavaScript Example which will help you

Here is the javacript code below


function onchangeaction(v){











And in the body section code:

<form action=”” method=”POST”>

<select onchange=”onchangeaction(this.value)”>

<option value=””>Select Fruit</option>

<option value=”mango”>Mango</option>

<option value=”banana”>Banana</option>



<select style=”display:none”>

<option value=””>Select Mango</option>

<option value=”Fazli”>Fazli</option>

<option value=”Gopalvog”>Gopalvog</option>



<select style=”display:none”>

<option value=”Select Banana”>Select Banana</option>

<option value=”Sagor”>sagor</option>

<option value=”Chinichampa”>chinichampa</option>



here is the output of the program

at the main page:

After Selecting Fruit Mango then the output:

after Selecting fruit Banana then the output:

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: