Yii Framework Forum: dropDownList onchange submit question? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

dropDownList onchange submit question? Rate Topic: -----

#1 User is offline   fibler 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 06-October 09

Posted 28 October 2009 - 04:20 PM

I was just wondering if anyone knows a way to have a dropDownList auto submit and keep the url search engine friendly?

this is my code... it work but uses ?id=1 instead of /id/1

CHtml::dropDownList('id', $select, $list, array('onchange'=>'this.form.submit()'))

0

#2 User is offline   fibler 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 06-October 09

Posted 28 October 2009 - 05:19 PM

I changed my form to POST and used this method...

CHtml::dropDownList('id', $select, $list, array('submit'=>'controller/action'));


Which works fine and uses jquery... i'd still like to know a way to use GET and submit the form value via friendly url?
1

#3 User is offline   Eliovir 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 69
  • Joined: 17-January 09

Posted 29 October 2009 - 01:12 AM

I'm using this

<?= CHtml::form(); ?>
        <?= CHtml::dropDownList('id', $select, $list, array('submit' => '')) ?>
<?= CHtml::endForm(); ?>

2

#4 User is offline   fibler 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 06-October 09

Posted 29 October 2009 - 09:13 AM

Yeah that's what im doing and it works for $_POST method. Is there a way to use dropdown with $_GET and maintain friendly URL's?

So onchange of dropDownList your url is /controller/action/id/1 instead of /controller/action/?id=1
0

#5 User is offline   mvpind 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 17-December 09

Posted 26 January 2010 - 01:20 AM

how to onchange function in dropdownlist
0

#6 User is offline   logos010 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 75
  • Joined: 12-November 10
  • Location:VietNam

Posted 12 November 2010 - 11:45 PM

View Postmvpind, on 26 January 2010 - 01:20 AM, said:

how to onchange function in dropdownlist

Hi, i am new guy in Yii to, but i think somethings i can share with you:
If you want to give an onchange function in dropdownlist, you can following this code:

CHtml::dropDownList(
'select_box_name',
'select_value',
$data,
array(
'onchange' => 'alert(1)',
)
);
where $data is an array of listData
hope can help you :rolleyes:
0

#7 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,448
  • Joined: 04-October 10

Posted 13 November 2010 - 12:16 AM

If you are planning to use onchange and wishes to use $_GET you need to set up you ajax to use method get instead of post.
┬┐How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#8 User is offline   Ivica 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 316
  • Joined: 25-May 11

Posted 21 July 2011 - 04:55 AM

Have you setup urlManager in config file and in .htaccess to create friendly urls?

By the way, why you want to use SEO friendly URLs, on form submission pages, they will not be indexed by search engine anyway.
Zurmo: Yii Powered Open Source CRM
zurmo.org
0

#9 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,340
  • Joined: 12-October 09
  • Location:Croatia

Posted 21 July 2011 - 05:11 AM

@Ivica note that you are posting on an old thread (last response from november 2010)... and in the Yii 1.0.x sub-forum (deprecated)...
Find more about me.... btw. Do you know your WAN IP?
0

#10 User is offline   Rajith R 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 873
  • Joined: 20-April 11
  • Location:India

Posted 05 September 2011 - 12:39 AM

View Postmdomba, on 21 July 2011 - 05:11 AM, said:

@Ivica note that you are posting on an old thread (last response from november 2010)... and in the Yii 1.0.x sub-forum (deprecated)...


Help me mdomba ...

i want to post the form onchange, what to do?
Rajith Ramachandran,
Wiwo inc.
| Mobile: 919995504508
0

#11 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 05 September 2011 - 02:03 AM

View PostRajith R, on 05 September 2011 - 12:39 AM, said:

what to do?

Start a new topic in the Yii 1.1 forum, please. :)
"Less noise - more signal"
0

#12 User is offline   Rajith R 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 873
  • Joined: 20-April 11
  • Location:India

Posted 05 September 2011 - 06:17 AM

View Postjacmoe, on 05 September 2011 - 02:03 AM, said:

Start a new topic in the Yii 1.1 forum, please. :)


got it myfriend,

<?php echo CHtml::dropDownList('id','select_value',$data,array('prompt'=>'Move To Folder','submit'=>array('user/inbox'))
);?>


or

<?php echo CHtml::dropDownList('id','select_value',$data,array('prompt'=>'Move To Folder','submit'=>'user/inbox')
);?>


*where data may CHtml::listData(.........)
**user/inbox replace controller/action
Rajith Ramachandran,
Wiwo inc.
| Mobile: 919995504508
2

#13 User is offline   richa 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 21-July 11

Posted 07 April 2012 - 12:52 AM

Hi Rajith,

I am using a similar thing as u mentioned above. I want to pass some values to the action. How do i do this?
0

#14 User is offline   Degger 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 09-April 12

Posted 09 April 2012 - 09:55 AM

View Postricha, on 07 April 2012 - 12:52 AM, said:

Hi Rajith,

I am using a similar thing as u mentioned above. I want to pass some values to the action. How do i do this?


<?php echo CHtml::dropDownList('license_id', 'license', 
              License::items(),
              array(
	              'empty'=>'Select License for this order',
	              'class'=>'span4',
	              'submit'=>array('order/addLicense', 'id'=>$model->orid), // id - will be sent as part of URL
	              'params'=>array('license_id'=>'js: $(this).val()'),      // license_id will be send via POST and its value is selected value of dropDown
	              'csrf'=>true,                                            // CSRF turned on in main config
              ));
?>


Helpfull links:
http://www.yiiframew...-example-chtml/
http://www.yiiframework.com/wiki/24/
3

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

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