javascript - How do I access form element values using ruby without submitting the form? -


OK, I still have a comprehensive Ruby app behind Ruby running Ruby, this app needs input , But when I update the text box, I do not want to refresh the page. What do I mean:

I have a form that has two text boxes, one is called "starttime" and one is called "endtime" I pressed a button in some way When the value of these text boxes (which are typed in a user) needs to be found in Ruby. Is there anything equivalent to the JavaScript documentation? Format.starttime.value command but for Ruby? Or is there any way to submit form data, retrieve it, but do not refresh the page like using AJAX? I know that Ajax is used to manipulate DOM dynamically without refreshing the page, but I really need to retrieve the data. Any help would be greatly appreciated, I can not find it anywhere.

You can do it very easily. Give the start time and end time form elements a different ID (I use start date and endDate below) and you can easily retrieve them, then You can send data in a Rail operation and process them in the background and if necessary, update the DOM with any relevant data when you click on a button (ID SendDateValues ​​ Confirms.)

something like this (not tested)

  & lt; Script type = "text / javascript" & gt; // $ ("# SendDateValues") (function () {$ .ajax ({url: '/ some controller / process data / data', data: 'startDate =' + $ ("# startdate") .val () + "& EndDate =" + $ ("# end date"). Val (), success: function (html) {// do something with result}, type: 'post'});}); // $]  

Run with the result ... Use firebug or check anything similar to what happens. Check your Rail Event Log What data did your action occur?


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -