First you would create a form alter function and make the taxonomy field as hidden and add ajax functionality to the node reference field. I am assuming that then node reference field widget is a select list.
For the following example I am assuming your fields are in the Basic Page. you can change the function name to suite your requirement by changing the mymodulename and page.
I am assuming the field name of the term reference field is field_vote and the node reference field is field_debate
function mymodulename_form_page_node_form_alter(&$form, &$form_state, $form_id) {
// We add the ajax functionality to the node reference field.
$form['field_debate']['#ajax'] = array(
// #ajax has two required keys: callback and wrapper.
// 'callback' is a function that will be called when this element changes.
'callback' => 'vote_field_return',
// 'wrapper' is the HTML id of the page element that will be replaced.
'wrapper' => 'replace_vote_div',
);
// Add a wrapper around the taxonomy field.
$form['#prefix'] = '<div id="replace_vote_div">';
$form['#suffix'] = '</div>';
// Check the form state to see if the debate field is filled.
if (!empty($form_state['values']['field_debate'])) {
// Load the debate node.
$debate = node_load($form_state['values']['field_debate']);
$form['field_vote']['#type'] = 'select';
// Assuming the taxonomy field in debate content type is field_vote_debate
// Some times the language for the field might be different from the language of
// the node itself in this case you might want to look at a dump of the $date
// field and make the required changes.
foreach($debate->field_vote_debate['$debate->language'] as $vote_term) {
$form['field_vote']['#options'][$vote_term['taxonomy_term']->tid] = $vote_term['taxonomy_term']->name;
}
}
else {
// Hide the taxonomy field to start of with.
$form['field_vote']['#type'] = 'hidden';
}
}
The call back function is pretty straight forward we simply return the field_vote so that it can be rendered again in the form
function vote_field_return($form, $form_state) {
// The form has already been submitted and updated. We can return the replaced
// item as it is.
return $form['field_vote'];
}
Note: As per the comment Please find below the updated code if the node ID is coming from url
I am assuming that the url to add the vote node is as follows
http://example.com/node/add/vote/23
where 23 is the node ID of the debate content type.
function mymodulename_form_vote_node_form_alter(&$form, &$form_state, $form_id) {
// We use the arg() function to get the argument from the url. The numbering
// starts from 0 and the one we need would be at 3.
$debate = node_load(arg(3));
// Assuming the taxonomy field in debate content type is field_vote_debate.
// Some times the language for the field might be different from the language of
// the node itself in this case you might want to look at a dump of the $date
// field and make the required changes.
foreach($debate->field_please_vote['$debate->language'] as $vote_term) {
$term = taxonomy_term_load($vote_term['tid']);
$form['field_vote']['und']['#options'][$vote_term['tid']] = $term->name;
}
}