/    Sign up×
Community /Pin to ProfileBookmark

PHP/JavaScript Dropdown option onChange

I’m trying to implement mutiple dropdown select option. I have to display table column & data in the next page based on the display or column order the user selects..so it is basically reordering table column in JavaScript. Any help will be greatly appreciated. Thanks in advance.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@kingdmJun 09.2010 — Hi shiva.

As I far as I understand your concern, I guess what you really need is a multiple drop-down written in JavaScript, then the PHP can be used to fetch the values from those drop-down. Try googling for it, learn from it then write your own to suit what you want, post it in the JavaScript section if ever you have any problems.

Cheers. ?
Copy linkTweet thisAlerts:
@shiva_mariselaauthorJun 11.2010 — This is what I'm trying to achieve..When user selects value 2 from the first dropdown, it should change value of second dropdown 'order2' to 1..basically swapping the value of two different dropdown.

In the Javascript I check if the selected value from first drop down matches the element from second drop down..but I can't put a logic to swap values

<tr><td>

<select name='order1' onchange='UpdateColumnOrder(this)' >

<option value=1 >1</option>

<option value=2 >2</option>

<option value=3 >3</option>

</select>

</tr></td>

<!-- second drop downdown box -->

<tr><td>

<select name='order2' onchange='UpdateColumnOrder(this)' >

<option value=1 >1</option>

<option value=2 selected >2</option>

<option value=3 >3</option>

</select>

</tr></td>



function UpdateColumnOrder(elt){

//check for duplicate selections

var form=elt.form;

var name=elt.name;

var index=elt.selectedIndex

//loop through all form elements

for(var i=0;i<form.length;i++){

var_name=form.elements[i].name;

var_index=form.elements[i].selectedIndex;



// if form element is not the current element

// and the division name is the same, raise

//error message

if(var_name!=name&&index!=0&&var_index==index){

elt.selectedIndex=0;

elt.focus();

return false;

}

}

return true;

}
×

Success!

Help @shiva_marisela spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...