0

I created the following script, but it does not display the decription texts for each option. In the HTML every var shows the correct value:

$available_methods = $existing_user->getMemberCashoutMethods();
print '<form name="combowithtext">';
print '<select name="example" size="1" onChange="showtext()">';
foreach($available_methods as $method) {
print '<option value="'.$method[name].'">'.$method[name].'</option>';
}
print '</select>';
print '<input type="button" value="Go!"><br>';
print '<textarea rows=5 cols=21 wrap="virtual" name="text"></textarea>';
print '<script language="javascript">';
print '<!-- ';
print 'var descriptions=new Array() ';
$i=0;
foreach($available_methods as $desc) {
print ' descriptions['.$i.']="'.$desc[instructions].'" ';
$i=$i+1;
}
print 'document.combowithtext.text.value=descriptions[document.combowithtext.example.selectedIndex] ';
print 'function showtext(){ ';
print 'document.combowithtext.text.value=descriptions[document.combowithtext.example.selectedIndex] ';
print '} ';
print '//-->';
print '</script>';
print '</form>';

Edited by tobik999: n/a

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Taywin
0
$method[name]
$desc[instructions]

Are you sure that it is correct? Shouldn't it be string instead of just plain variable-liked inside the []? (i.e. $method["name"] and $desc["instructions"])

Edited by Taywin: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.