Yii Framework Forum: Textbox Value To Url - Yii Framework Forum

Jump to content

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

Textbox Value To Url Rate Topic: -----

#1 User is offline   Bluenica 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 69
  • Joined: 19-February 13

Posted 28 May 2013 - 04:53 AM

Hi everyone...
i have this form
<form name=form1 method="post">
    Quarter: &nbsp;
	<select style="width:150px">
	<option value="0"></option>}
	<option value="1">1</option>
	<option value="2">2</option>
	<option value="3">3</option>
	<option value="4">4</option>
	</select> 	
	<br><br>
	
	Year: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
	<input type="text" name="year" style="width:145px"/><br><br>	
	
	Site: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<select>
	  <option value="Select"></option>}
	  <option value="1">ALL SITES</option>
	  <option value="1">BAGUIO</option>
	  <option value="2">LA UNION</option>
	  <option value="3">ALBAY</option>
	  <option value="4">NCR</option>
	  <option value="5">DAVAO</option>
	  <option value="6">ZAMBOANGA</option>
	  <option value="7">RIZAL</option>
	  <option value="8">SOUTH COTABATO</option>
	  <option value="9">SAMAR</option>
	</select> <br><br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;


and this as the link or output
	<?php 
	$year = @$_GET['year'];
	$year = @$_POST['year'];
	
	echo CHtml::link('GENERATE REPORT', array('index','type'=>ireport, 'file' => 'ASQBorderline','site'=>'BAGUIO','Year'=>$year,'Quarter'=>'2')) 
	?>

now my problem is how will i get the value of the quarter[dropdown], the year[which is a textfield] and the site[which is also a dropdown] to the url .. i am currently trying to get the year first that's why my code is like that .... this is for a report generation.
thanks in advance for all your help. :)
0

#2 User is offline   Keith 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,670
  • Joined: 04-March 10
  • Location:UK

Posted 28 May 2013 - 05:03 AM

You haven't given either select element a name, so you won't be able to identify them in PHP. You need something like:

<select name="quarter">
    ...
</select>


Which you can retrieve with:

$quarter = Yii::app()->request->getParam('quarter');


That's assuming that you need to be able to get the value from both GET and POST.

Also, you should really be generating your forms using CHtml's methods, especially when opening the form. If you ever want to add CSRF protection, you're going to have to go back and edit every form you've created.
0

#3 User is offline   Bluenica 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 69
  • Joined: 19-February 13

Posted 28 May 2013 - 07:10 AM

View PostKeith, on 28 May 2013 - 05:03 AM, said:

You haven't given either select element a name, so you won't be able to identify them in PHP. You need something like:

<select name="quarter">
    ...
</select>


Which you can retrieve with:

$quarter = Yii::app()->request->getParam('quarter');


That's assuming that you need to be able to get the value from both GET and POST.

Also, you should really be generating your forms using CHtml's methods, especially when opening the form. If you ever want to add CSRF protection, you're going to have to go back and edit every form you've created.


this works fine but what about in dropdown ... i couldn't get the values chosen. thank you in advance
0

#4 User is offline   Keith 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,670
  • Joined: 04-March 10
  • Location:UK

Posted 28 May 2013 - 07:18 AM

What I said above will get the value of the dropdown. You need to give more detail about what's not working for you or what you're expecting to happen.
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