Skip to main content

Posts

Showing posts with the label forms

How not to lose focus on a login page

I have a simple login form with 2 input fields: "username" and "password". "username" field is focused by default. The problem is that when user clicks outside "username" or "password" fields, the focus is gone (it is neither on "username" nor on "password" fields"). How can I force the focus to be on these 2 fields only ?

Prevent Back button from showing POST confirmation alert

I have an application that supplies long list of parameters to a web page, so I have to use POST instead of GET. The problem is that when page gets displayed and user clicks the Back button, Firefox shows up a warning: To display this page, Firefox must send information that will repeat any action (such as a search or order confirmation) that was performed earlier. Since application is built in such way that going Back is a quite common operation, this is really annoying to end users. Basically, I would like to do it the way this page does: http://www.pikanya.net/testcache/ Enter something, submit, and click Back button. No warning, it just goes back. Googling I found out that this might be a bug in Firefox 3, but I'd like to somehow get this behavior even after they "fix" it. I guess it could be doable with some HTTP headers, but which exactly? Source: Tips4all

Using jquery.calculation.js with dynamically added form fields

I'm creating a form with dynamically added fields and would like to sum all added fields. So far I have the following code, but it only sums the first row: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Totals</title> <script type="text/javascript" src="../js/jquery/jquery-1.6.2.js"></script> <script type="text/javascript" src="../js/jquery/jquery.calculation.js"></script> <script type="text/javascript"> //Sum $(document).ready( function (){ $('input[name^=reds]').sum("keyup", "#totalSumReds"); $("input[name^=blues]").sum("keyup", "#totalSumBlues"); } ); </script> <script type="text/javascript"> //Add/remove form fields jQuery(func

Trigger a form submit on a different page - Rails 3

So, I have a form on page 'A' which lets users type in the name of a band and see album covers and prices, courtesy of the Amazon API. <%= form_tag(amazon_path, :method => 'get') do %> <h3> Search for Albums </h3> <%= label_tag(:amazon_search_form, "by Band/Artist:") %> <%= text_field_tag(:amazon_search_form) %> <%= submit_tag("Search") %> <% end %> Users can also see all bands they are following on their profile page. From their profile page, they are able to select a band 'b' (perhaps by clicking on the band's img). After that, if they click on the link to go to page 'A', I would like the form to be automatically submitted with band 'b's name so that the user won't have to type in the name of band 'b' to see the albums for band 'b'. I can't tell if jQuery's .submit function can pass a parameter of the band's name to the form when

Some form values not getting submitted after using .replaceWith()

Let's say I have this form: <form action="submit" method="post"> <select name="category" id="categorylist"> <option value="love">Love</option> <option value="magic">Magic</option> <option value="custom">Custom</option> </select> <textarea name="content">SomeContent</textarea> <input type="submit"> </form> I wanted to change the select into an input when I select custom so I came up with this: $(function(){ $('#categorylist').change(function(){ $(this).replaceWith('<input type="text" name="category">'); }); if( $('#categorylist').val() == 'custom' ) $('#categorylist').replaceWith('<input type="text" name="category">'); }); But when the select is changed into an input, $_POST['category'] is

mysql row turning into attributes

I need help with an <input> . Some times when I call for the var to be inserted into the value="" part of the <input> it makes every word into an attribute. For example my tag will look like this <input type="hidden" name="article" this="" is="" the="" article="" text="" /> and the call to the <input> is this echo '<input type="hidden" name="article" value="'.$row['article'].'" />'; below is the actual code CODE: echo '<input type="hidden" name="date_added" value="'.$row['date_added'].'" />'; echo '<input type="hidden" name="id" value="'.$row['id'].'" />'; echo '<input type="hidden" name="article" value="'.$row['article'].'" />'; echo

Mocking a JSP"s post method versus creation an API

I have an requirement as per which I have to call an existing java function which is called from the UI through jsp. Data is provided from a form. I want to call that function from the java code. Should I create an API which should be called from the java code, and pass all the parameters required for the java function OR create a mock of the form(if its possible) and pass it to jsp. What is the recommended way?

PHP from quotation mark output

I use a similar form on a regular basis and have just become aware that whenever a single OR double quotation mark is inputted into the form the output to myself (through email) displays the quotation mark as the ASCII code so \' with a backslash ive looked around and dipped into unique character encodings specialentities but cant seem to find anything that will help output it as a normal quotation mark.

Stretching a HTML Input Box alongside additional input?

I'm using jQuery on this site, which has form inputs. I'd like one particular field to get longer (width) as the user enters data and space runs out. How can I calculate when I ACTUALLY need to make the input ( type="text" ) longer? What works for one browser may not work for all browsers. Is this something that can't be calculated, so everybody does it based on trial and error within each browser? Will I need to resort to this and tweak stretch values with a .keyup() that checks the value?.. EG.. $(".stretchInput").keyup( function(event) { var someValueAdjustedByTrialAndError = 30; var stretchPastLength = someValueAdjustedByTrialAndError; var stretchBy = 5; var baseWidth = 100; if ($(this).val().length > stretchPastLength ) { $(this).css('width',(baseWidth + ($(this).val().length - stretchPastLength ) * stretchBy ) + 'px'); } else { $(this).css('width',''); } });

Keep form values after page reload - Codeigniter

How can I keep checkboxes selected after the form has been submitted? I found the set_checkbox function in the Codeigniter User Guide, but it doesn't work. Form field code from the User Guide <input type="checkbox" name="mycheck" value="1" <?php echo set_checkbox('mycheck', '1'); ?> /> <input type="checkbox" name="mycheck" value="2" <?php echo set_checkbox('mycheck', '2'); ?> /> I also googled this and found a couple of workarounds, but they were based on previous versions of Codeigniter. And they were based on Form Validation, which isn't necessary for my form, because none of the fields are required. How can I retain the checkbox field value after the form is submitted? UPDATE : This question is not about form validation and errors. I want to retain the checkbox field value AFTER the page is reloaded. Is jquery a possibility?

Validate field, select or checkbox without form tag

Good day, I found a lot of topics about that, but, without a proper answer. Many of topics ended with question why you just can't add form? I'm working on a project that based on ASP.NET and I have one form tag, one form tag that contains all the html code inside it. I can't use any ASP.NET controls and must done validation by front-end (jQuery). Everything is fine when there is only one form and one submit button, then I can use simple query validation plugin, but it gets complicated when I have more than one form and of course more than one submit button. Any suggestion, ideas or real example how to do that? Maybe I can somehow put every field and submit button inside a div and validate them by submit within that div? Thank you!

Display hidden form field based on select box choice

Here is a form element I have. <select id="state" name="state" style="width: 212px;"> <option value="nsw">New South Wales</option> <option value="qld">Queensland</option> <option value="vic">Victoria</option> <option value="nt">Northern Territory</option> <option value="tas">Tasmania</option> <option value="sa">South Australia</option> <option value="wa">Western Australia</option> <option value="act">Australian Capital Territory</option> <option value="notinoz">Not in Australia</option> </select> What I want to do is below this add another select box element , if user chooses "not in Australia" in the options above. I am really after the cleanest lightest code possbile. I am presuming we create a div and set visibility:hidden just no