• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

html, javascript, php question

Jay59express

Senior member
Hi,
I have two <select> menus that get populated by information from a file by php. They both contain the same elements. The second menu is hidden in a layer and gets shown when the user clicks a radio button. What I would like to be able to do is have the second menu have the option that is selected in the first menu be selected. So I guess the basic question is whether or not it is possible to have the selected value in a <select> menu be changed without having to repopulate it.

some variables:
<form name = publishForm>
<select name = tech...> 1st menu
<select multiple name = data_techs[] (this is technically a select multiple, but I just want to set one value, namely the one that matches tech)
 
function selectOption(arg){
var formName = 'checkout_b';
var selectName = 's_state';
if(arg != ''){
for(var i=0;i<eval("document." + formName + "." + selectName + ".length");i++){
if(eval("document." + formName + "." + selectName + ".options.value") == arg){
eval("document." + formName + "." + selectName + ".selectedIndex = i");
}
}
}
}


arg should be the value you want to set as active. you figure out the rest 🙂
 
Back
Top