Yii Framework Forum: 将View的值传递到Model - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

将View的值传递到Model Rate Topic: -----

#1 User is offline   life_free 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 26-September 12

Posted 09 October 2012 - 12:36 AM

如何将view的值传递到model?]
view中的admin.php
<form id="serverform" name="serverform">	
<select name="server" id="server" onchange="return chooseServer();">
	<option value="aa1">aa1 Server</option>
	<option value="aa2">aa2 Server</option>		
</select>


现在我需要把下拉框选定的值传递给model/users.php 的一个自定义静态变量public static $db ,如何操作呢?万分感谢!!!
0

#2 User is offline   hehbhehb 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 50
  • Joined: 24-February 12

Posted 09 October 2012 - 06:49 AM

onchange时下拉框的值是先到controller中的, controller收到后,再传给model吧
0

#3 User is offline   life_free 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 26-September 12

Posted 09 October 2012 - 08:41 PM

View Posthehbhehb, on 09 October 2012 - 06:49 AM, said:

onchange时下拉框的值是先到controller中的, controller收到后,再传给model吧



谢谢啊!那能不能直接将值传过去呢? 有什么方法么?
这是我的 chooseServer()方法
function chooseServer(){
	var server = document.getElementById('server').value;
	alert (server);	
	<?php		
	echo CHtml::ajax(
	array(
		
		"data" => "js:{servers : server}",
		"type"=>"POST",
		"success" => "function(psw) { alert(psw);}"
	)
);
	?>
	// history.go(0);	
}

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users