JuniorBee
asked on
Copy dynamic select field value to a text field in another form on the same page
I have a select field that is created on the fly and there are 2 forms on the page. I don't want to have the select field on the page twice in both forms but I need that value for both forms, whichever the user selects to submit.
So I would like to have the select field display in the first form, then whatever is selected, copies to a hidden text field in the 2nd form.
I am attaching thee code that displays the drop down/select field
So I would like to have the select field display in the first form, then whatever is selected, copies to a hidden text field in the 2nd form.
I am attaching thee code that displays the drop down/select field
<?php // select drop-downs?
if($attr_option == 1){
echo get_attribute_dropdown($post->ID);
}
elseif($attr_option == 2){
echo get_attribute_dropdown($post->ID,2,$basis_price); else{}
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Can we see what you're trying to do?
ASKER
I seem to have gotten it to work, thanks!
ASKER
oh is there a way to get it to load when the page loads also? So that the hidden form has the same thing as the first selection in the dropdown?
Try:
window.onload = function() {
var select = document.getElementById('mySelect');
var hidden = document.getElementById('myHiddenInput');
select.onchange = function() {
hidden.value = this.value;
};
hidden.value = select.value;
};
ASKER
thanks!
ASKER