简体   繁体   English

Joomla>选定的下拉列表不传递到服务器

[英]Joomla> Selected Drop Down Not passing to Server

I know I am missing something basic here, but for the life of me, I cannot figure this out. 我知道我在这里缺少一些基本的东西,但是对于我的一生,我无法弄清楚。

I need the hidden input field to reflect the course selected by the user in the drop down. 我需要隐藏的输入字段以反映用户在下拉菜单中选择的课程。

===================================================================== ================================================== ===================

<p><b>1. Select Course:</b></p>
<?php

$db = JFactory :: getDBO();
$query = "select name from #__guru_category  order by name ASC";
$db->setQuery($query);
$result = $db->loadObjectList();
$options = array(); 
$options[] = JHTML::_('select.option','Select Course');
foreach($result as $row)
{
$options[] = JHTML::_('select.option', $row->name);
}
$dropdown = JHTML::_('select.genericlist', $options, 'class="inputbox"', 'subject', 'value', 'text');
echo $dropdown; 

?>
<p><b>2. Select assignment file to upload:</b></p>
<p><input type="file" name="fileToUpload" id="fileToUpload"></p>
**<input type="hidden" name="subject" id="subject" value="">**
<p><input type="submit" value="Upload Assignment File" name="submit"></p>

</form>

==================================================== ================================================== ==

$dropdown = JHTML::_('select.genericlist', $options, 'class="inputbox"', 'subject', 'value', 'text');

You have missplaced the argument value orderlist 您放错了参数值顺序列表

genericlist($arr, $name, $attribs=null, $key= 'value', $text= 'text', $selected=NULL, $idtag=false, $translate=false)

folow the link: https://docs.joomla.org/API15:JHTMLSelect/genericlist 按照链接: https ://docs.joomla.org/API15:JHTMLSelect/genericlist

Here the solution 这是解决方案

<?php
$db = JFactory :: getDBO();
$query = "select name from #__guru_category  order by name ASC";
$db->setQuery($query);
$result = $db->loadObjectList();

$options = array(); 
$attr  = 'onchange="UpdateUsername(this.options[this.selectedIndex].value);"';
$attr .= ' class="inputbox"';

$options[] = JHTML::_('select.option','Select Course');
foreach($result as $row){
    $options[] = JHTML::_('select.option', $row->name);
}
$dropdown = JHTML::_('select.genericlist', $options,'subject',$attr, 'value', 'text');
echo $dropdown; 

?>
<p><b>2. Select assignment file to upload:</b></p>
<p><input type="file" name="fileToUpload" id="fileToUpload"></p>
<input type="hidden" name="subject" id="subject" value="">
<p><input type="submit" value="Upload Assignment File" name="submit"></p>
<script type="text/javascript">
function UpdateUsername(selected){
 document.getElementById(subject).value= selected;  
}
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM