dynamic id to textbox - codeigniter-2

I am creating dynamic textbox and button in codeigniter view page through foreach loop. Then I want to retrieve the value of those textboxes on buttton click. please help me. Thank you.

Add a counter and attach the counter at end of textbox names so that dynamically created textboxes have names like textbox1, textbox2 etc. In controller's submit function run the loop again and fetch the values.
Regards
iijb

Related

How do I get Dropdown SelectedItem text in view model in ASP.NET MVC 3

This is my Razor view in ASP.NET MVC3 Application
#Html.DropDownListFor(m => m.Leave_Type, Model.Leave_Types, new { #class = "input-append" })
On POST when I read Model.LeaveType, it returns selected value. I want to get the selected text instead, how do I get it? I appreciate any help. Thanks a lot in advance!!
The answer is.. it depends. A drop down is just a standard HTML dropdown control, and it can only post the selected value. It will never post the text, and there is no way to change that.
Do you need the selected value as well? If so, then you can't get both like that. You would have to look up the Leave_Type text in the Leave_Types object based on the selected value returned.
If you don't need the Leave_Type, then you can simply use the text for both the value and text.
Another option might be to write some javascript that copies the selected item text to a hidden field whenever the value of the dropdown changes. Then that hidden field will be posted and you can check that.
I would, however, simply look up the value in whatever method you use to create the Leave_Types collection in the first place.

<form:input> inside of <form:select> How to realize?

I'm building a jsp which will let user select data from database, it will uploads when page will render for user. But the problem is <form:select> don't let user insert new value his own one if the value not represented in the list(doesn't inputed in database).
I need let user put his own value if it's doesn't not exist in the <form:select>.
It's kinda has to be <form:input> with <form:select><form:options items="myList"></form:select>.
Could you help me with this. Thank you
You can provide textbox and dropdown.Make textbox enable only if user didnt select any value from dropdown allow him to enter value. If he selected any value from dropdown make the textbox disable.for this you should use bit of jquery or javascript.

Select item in a gridview

I'm trying to create a webpage where a user can click on an item inside a gridview and have that rows data display in another page. I cannot figure out how to set it up so only the selected row's information is displayed in (I am thinking I will use a form view to display the data on the second page) the form view on the second page. Any suggestions?
Thanks!
Jake
If you have just a couple of columns i did suggest you to use QueryString to pass values between pages. Lets say there are two such values you want to pass to another page:
Response.Redirect("default2.aspx?firstvalue=" + yourfirstvalue + "&secondvalue=" + yoursecondvalue");
// this will set the values you want to pass on your gridview page
Request.QueryString("firstvalue")
// this will retrieve the first value from URL from your second page
If you want a neat lookin URL then i would suggest you to use Session variables.

How to get MVC web grid dropdown column value using javascript or from controller

We have a dropdown list column in ASP.NET MVC 3.0 WebGrid. User will select a item from that list for each row.
When i click on submit I need to capture the selected value for each row.
Can anyone please give me a sample code for doing this from controller.
Thanks in advance
You can make a column with DropDownList control using a html helper:
grid.Column("List", header: "List", format: #<text>#Html.DropDownList("selection", someItems)</text>)
Then put the whole grid in a "form" statement, which refers to "Save" action in your controller, and create that "Save" action method like this:
public ActionResult Save(string[] selection) {
[...]
}
Why don'y you give telerik.mvc grid a try. It's super smooth and handles such scenarios pretty well. Moreover the effort is pretty less in setting it up.
You can download it as a nuget package.
Examples are here http://demos.telerik.com/aspnet-mvc/grid

onselect in one combo it changes data dynamically in other combo?

Hello sir I am new to the jsp and ajax world. my problem is
If i select one combo option then it should change the other combo options dynamically without submit button press.
for example if i select the country then it should shows their states in other combo.
I am using servlet & JSP and MS-ACCESS as backend. please reply as soon as possible.
THANKING YOU....
You need:
A piece of JSP which returns a string which can be parsed in javascript to create a list of possible combobox items (value, name) to select in the SECOND combobox, based on a VALUE which can be selected in the FIRST combobox
A piece of javascript which receives the onChange event of the FIRST combobox and uses the then selected value to create a XMLHTTP-request to your JSP (at 1)
A piece of javascript which you can pass to the XMLHTTP-request onReadyStateChange event to execute, which reads/parses the parseable string (from 1) and fills the second COMBOBOX with those values
Good luck

Resources