小编Ang*_*ine的帖子

如何使用Java连接到远程MySQL数据库?

我正在尝试使用Eclipse IDE创建一个JSF应用程序.我使用远程mySQL服务器作为我的数据库.如何连接到此远程数据库以创建表并访问它们?

java mysql eclipse jdbc

26
推荐指数
2
解决办法
10万
查看次数

foreach相当于jquery中的php?

在PHP中是否存在JQuery中的foreach代码?我在php中有一个代码,比如

<?php foreach ($viewfields as $viewfield): ?>       
if("<?php echo $viewfield['Attribute']['required'];?>"=='true'){
       $("<span class='req'><em> * </em></span>").appendTo("#fb_contentarea_col1down21 #label<?php echo $viewfield['Attribute']['sequence_no']?>");
   }


   if(<?=$viewfield['Attribute']['type'];?>=='text'||<?=$viewfield['Attribute']['type'];?>=='date'||<?=$viewfield['Attribute']['type'];?>=='number'){ 
       $("<input id=input<?=$viewfield['Attribute']['sequence_no'];?> type= 'text' style= 'width:<?=$viewfield['Attribute']['size'];?>px' data-attr=<?=$viewfield['Attribute']['type'];?> ></input><br>").appendTo("#fb_contentarea_col1down21 #<?=$viewfield['Attribute']['sequence_no'];?>");
   }


   else if(<?=$viewfield['Attribute']['type'];?>=='textarea'){
       $("<textarea style= 'width:<?=$viewfield['Attribute']['size'];?>px' data-attr=<?=$viewfield['Attribute']['type'];?> id=input<?=$viewfield['Attribute']['sequence_no'];?>></textarea><br>").appendTo("#fb_contentarea_col1down21 #<?=$viewfield['Attribute']['sequence_no'];?>");
}
Run Code Online (Sandbox Code Playgroud)

在Jquery中有没有相当于foreach的东西?如何在jQuery中实现相同的功能?

编辑1:

我认为它有效,但我得到一个错误.代码和错误消息如下.

for(<?=$viewfield;?> in <?=$viewfields;?>){

 if("<?=$viewfield['Attribute']['required'];?>"=='true'){
            $("<span class='req'><em> * </em></span>").appendTo("#fb_contentarea_col1down21 #label<?php echo $viewfield['Attribute']['sequence_no']?>");
 }

 if(<?=$viewfield['Attribute']['type'];?>=='text'||<?=$viewfield['Attribute']['type'];?>=='date'||<?=$viewfield['Attribute']['type'];?>=='number'){ 
            $("<input id=input<?=$viewfield['Attribute']['sequence_no'];?> type= 'text' style= 'width:<?=$viewfield['Attribute']['size'];?>px' data-attr=<?=$viewfield['Attribute']['type'];?> ></input><br>").appendTo("#fb_contentarea_col1down21 #<?=$viewfield['Attribute']['sequence_no'];?>");
 }

 else if(<?=$viewfield['Attribute']['type'];?>=='textarea'){
            $("<textarea style= 'width:<?=$viewfield['Attribute']['size'];?>px' data-attr=<?=$viewfield['Attribute']['type'];?> id=input<?=$viewfield['Attribute']['sequence_no'];?>></textarea><br>").appendTo("#fb_contentarea_col1down21 #<?=$viewfield['Attribute']['sequence_no'];?>");
 }
Run Code Online (Sandbox Code Playgroud)

}

错误信息:

(在数组中)的语法错误

有人能帮我吗..

php foreach jquery

14
推荐指数
4
解决办法
3万
查看次数

在jQuery中迭代PHP数组?

如何在jQuery中迭代PHP数组?我在PHP中有一个名为的数组$viewfields.如何使用jQuery迭代此数组的每个元素?

编辑1

<?php foreach ($viewfields as $view): ?>           

if(<?=$view['Attribute']['type'];?>=='text'||<?=$view['Attribute']['type'];?>=='number')
{ 
     $("<input id=input<?=$view['Attribute']['sequence_no'];?> type= 'text' style= 'width:<?=$view['Attribute']['size'];?>px' data-attr=<?=$view['Attribute']['type'];?> ></input><br>").appendTo("#fb_contentarea_col1down21 #<?=$view['Attribute']['sequence_no'];?>");
}
Run Code Online (Sandbox Code Playgroud)

如果我给

$.each(arrayfromPHP,function(i,elem){

}
Run Code Online (Sandbox Code Playgroud)

如何在jQuery中编写$ view ['Attribute'] ['type']的代码?我认为elem ['Attribute'] ['type']不起作用?

编辑2

elem ['Attribute'] ['type']确实有用

php arrays foreach jquery

12
推荐指数
1
解决办法
3万
查看次数

使用jquery.js和scriptaculous.js文件?

有没有办法同时使用jquery和scriptaculous js文件?

我试图实现cakephp框架的自动完成功能,该功能需要js文件,prototype.js,scriptaculous.js,effects.js和controls.js.

我还在我的应用程序中使用JQuery函数,它需要jquery.js文件.

如果我包含jquery.js文件,则自动完成功能不起作用.但我还需要jquery.js文件来实现我的jquery函数.

那么是否有任何方法可以同时使用js文件?

jquery conflict cakephp scriptaculous prototypejs

10
推荐指数
1
解决办法
1万
查看次数

我可以在一次点击功能中为2个id元素编码相同的功能吗?

有没有任何方法可以在一个单击函数中对两个不同id元素的click函数进行相同的编码?

例如,我有两个带有id的链接元素,myFormsTabSubmitted和formStatusSubmitted.这两个链接都具有相同的功能.当我单击这两个链接时,会显示相同的div元素("提交"),并隐藏其他div.

因此,不是编写两个单击函数,一个用于myFormsTabSubmitted,另一个用于formStatusSubmitted,我可以为这两个函数设置一个单击函数吗?喜欢

$('#myFormsTabSubmitted #formStatusSubmitted').click(function(){
            $('#allMyForms').hide();
            $('#draftedMyForms').hide();
            $('#submittedMyForms').show();
            $('#myFormsTab').find(".selected").removeClass();
            $('#myFormsTabSubmitted').addClass("selected");
        });
Run Code Online (Sandbox Code Playgroud)

jquery click

10
推荐指数
2
解决办法
9733
查看次数

如何在flex中居中对齐hbox中的按钮?

我有一个VBox,里面有4个HBox.第二级HBox最初是隐藏的.单击标签"显示更多选项"时,将显示第二级HBox.现在我将"二级HBOx"占用的空间置空,"搜索"按钮位于空间下方.

我的第一个问题是,有没有办法定位搜索按钮,使空间不存在,点击"显示更多选项"标签后,会出现"二级HBox"?

第二个问题是,我可以将搜索按钮放在页面的中心.是否有任何方法可以将VBox的HBox内容集中在一起?

这是我的代码:

<mx:Form x="47" y="219" width="80%" >


<mx:VBox id="searchBox" >
    <mx:HBox id="searchTitle"  width="100%" height="20" backgroundColor="#2680D5">
        <mx:Label text="Search Criteria" paddingRight="250" width="654.6212" height="18.030302"/>
         <mx:Label text="show more options" id="moreOption"  click="showOption(event)" width="127.045456" height="21.969696"/>

    </mx:HBox>

    <mx:HBox id="firstLevel" paddingBottom="10" paddingTop="15" >

        <mx:Label text="Task Name" paddingLeft="20"/>
        <mx:TextInput id="searchTaskName" paddingLeft="10" /> 

        <mx:Label text="Item Code"  paddingLeft="30"/>
        <mx:TextInput id="searchItemCode" paddingLeft="10"/>

        <mx:Label text="Task Type" paddingLeft="30"/>
        <mx:ComboBox id="searchTaskType" paddingLeft="10"/> 
    </mx:HBox>

    <mx:HBox id="secondLevel" visible="false" paddingTop="5">

        <mx:Label text="Task ID" paddingLeft="20" />
        <mx:TextInput id="searchTaskId" paddingLeft="10"/>



        <mx:Label text="Project Won" paddingLeft="30"/>
        <mx:ComboBox id="searchWon" paddingLeft="10"/>
    </mx:HBox> …
Run Code Online (Sandbox Code Playgroud)

apache-flex hbox center-align

10
推荐指数
1
解决办法
3万
查看次数

如何在jQuery中获取锚标记的id?

如何在jQuery中获取锚标记的id?这是标签.

 <ul class="formfield">
     <li class="selected"><a href="" id="text">Text</a></li>
     <li><a href="" id="textarea">Textarea</a></li>
 </ul>
Run Code Online (Sandbox Code Playgroud)

我需要在变量中获取id,即textarea,text等.

我尝试过类似的东西,但我认为没有fieldValue这样的东西.

$('.formfield a').click(function() {         
    fieldType=$('.formfield a').fieldValue();
    alert(fieldType);
});
Run Code Online (Sandbox Code Playgroud)

jquery

9
推荐指数
1
解决办法
6万
查看次数

如何在CakePHP中创建,编写和读取会话数据?

任何人都可以给我一个如何创建会话并向其写入数据的示例.我已经看到了如何使用write命令将数据写入会话的语法.但是如何创建会话并检索其中的值.

在我的应用程序中,我有两个数据,form_id和user_id,需要在所有页面请求中使用.那么如何将其保存为会话变量并在整个应用程序中使用它?

编辑

function register()
{
    $userId=$this->User->registerUser($this->data);
    $this->Session->write('User.UserId',$userId);
    //echo "session".$this->Session->read('User.UserId');
    $this->User->data=$this->data;
    if (!$this->User->validates())
    {
    $this->Flash('Please enter valid inputs','/forms' );
      return;   
    }

$this->Flash('User account created','/forms/homepage/'.$userId);            

}   
Run Code Online (Sandbox Code Playgroud)

如何在$ this-> Flash中使用会话变量'User.UserId'而不是$ userId('用户帐户创建','/ forms/homepage /'.$ userId);

我可以在所有视图文件中使用此变量,因为在所有页面请求中我还传递了userId吗?

编辑2

我有2个控制器,用户和表单.我将userid写入users _controller中的会话变量.我有一个名为homepage.ctp的视图文件,其操作在forms_controller中.现在我如何使用主页中users_controller中定义的会话变量?对不起,如果我问愚蠢的问题.我浏览了蛋糕书,但我的怀疑并没有被清除.我也在尝试编译的错误方法,所以请帮帮我.

编辑3

我有一个会话变量'uid',它是控制器主页操作中的用户ID.

       $this->Session->write('uid',$this->data['Form']['created_by']);
Run Code Online (Sandbox Code Playgroud)

我需要在同一个控制器的设计动作方法中使用相同的变量.当我给

             $uid=$this->Session->read('uid');
            echo "uid: ".$uid;
Run Code Online (Sandbox Code Playgroud)

价值没有回应.

我不能在同一个控制器中使用会话变量吗?

session cakephp-2.0

8
推荐指数
3
解决办法
5万
查看次数

如何在Flex中将数据网格导出到Excel文件?

如何将数据网格中的数据导出到Flex中Excel文件?

任何人都可以提供一些例子吗?我正在浏览,但无法找到这种类型的一个例子.

编辑

浏览了很多,并找到了如何将datagrid数据转换为csv格式.现在如何将其转换为excel?有没有办法在不使用任何服务器脚本的情况下执行此操作?难道不能单独在Flex中完成吗?

apache-flex flex3 actionscript-3 export-to-excel

8
推荐指数
1
解决办法
3万
查看次数

CakePHP中的重定向和渲染有什么区别?

是否还有其他命令可以将控制器重定向到除重定向和渲染之外的特定视图页面?

我有重定向作为

$this->redirect('/forms/homepage/'.$userId);
Run Code Online (Sandbox Code Playgroud)

但是,如果我给

$this->render('/forms/homepage/'.$userId);
Run Code Online (Sandbox Code Playgroud)

它不会被重定向到该页面.

有什么不对吗?

redirect cakephp

6
推荐指数
1
解决办法
2万
查看次数