Checkbox and Yes/No ASP.Net-Jquery - jquery-ui

I have a page where it populates questions. There are two types of questions.
First one Yes/No,
Second one multiple choice with checkboxes. The multiple choices varies from 2- 5.
Depending on the question I need to generate a string which can be used in aspx.cs file
The format of string is :
string value="1=true, 2=false,3=false,4= true"
if 1 and 4 options are selected(checkbox options).
The string format for Yes/No would be
string value= "1=false, 2= false, 3=false,4=false"
Could any body help me how To do this using jquery in asp.net
Thank you
Hari

Have you checked out serialize? http://api.jquery.com/serialize/

Related

Orbeon forms convert number from textfield into words?

i am creating orbeon form, so i write a script that can convert number into words,now is it possible to pass the parameter url in orbeon to read a text field and convert the number in to word in another textfield or populate another textfield from the url?
I'm not sure what you need. If you need get URL parameter you can use xxf:get-request-parameter() (https://doc.orbeon.com/xforms/xpath/extension-functions/extension-http#xxf-get-request-parameter). For example set this funciton as calculated value for some Text Field, publish form and test it in Runner.
If it not correct answer, please write more information about you problem.

Looking to fill out most or all of the Fed Ex "Create Label" page using URL query string

Looking to create a shipment on www.fedex.com
But fill out most of the fields using a query string at the end of a URL.
Seems like this might not be possible, but need help figuring out how to know whether it is or not.
My "Create Labels" page has a URL ending in -- ?method=doInitialize&utype=null ,
or else sometimes ...
-- ?method=doEntry&link=1&locale=en_US&urlparams=us&sType=F
so it seems promising. Just not sure how to access the names of the required fields (Contact name, Address 1 and 2, etc ) besides guess and check.
Thanks!
--------- Destination Section Parameters Found
The query string parameters for the destination contact field are, at the time this answer was written :
toData.addressData.contactName
toData.addressData.addressLine1
toData.addressData.addressLine2
toData.addressData.zipPostalCode
toData.addressData.city
toData.addressData.stateProvinceCode
toData.addressData.phoneNumber
psdData.mpsRowDataList[0].weight
Of course, they need to be appended to the original URL using valid query string syntax and URL encoding.
--------- How Were These Found ?
These were each found using the page inspector. I found that it is important to cut through the noise by zeroing in on the exact field where the data needs to be entered, and opening up the page inspector to that location.
Right click (Win) or control click (Mac) > "inspect"
This will bring up the following text in the inspector. By trial and error, I discovered that the "name" fields correspond to the working query string parameters.
The part we are looking for :
This corresponds to the query string parameter ...
toData.addressData.addressLine1
... originally listed above.
--------- Unsolved Parameters
It's a mystery why this same rule doesn't apply in the same way to other values in the page, like service type (e.g. "Priority Overnight") or package type (e.g. "FedEx Box"). The following, for example, do not fill as expected, even when using the exact same "name" field from the page inspector.
psdData.mpsRowDataList[0].carriageValue
psdData.serviceType
psdData.packageType
billingData.referenceData.yourReference
Maybe it's a URL encoding issue? Anyway, hope this helps.

How to fill in a datetime field with capybara?

I found this similar question How to fill in a datetime-local field with capybara?, and the only answer in this thread is not working. So I decided to open this question. It seems like there's no documentation or tutorial about this. Have any solution? It will be a great help!
The keys different browsers accept for setting a datetime input field are diffrent, however if you're using selenium with chrome and you are actually attempting to fill in a visible <input type="datetime-local"> element, as your question states, then the answer in the question your linked to should work - Here is a gist that shows it working - https://gist.github.com/twalpole/a541746b354afde8e82fa89a35a9b2da
The important part in that answer is the format of the string you send since it needs to match the keys the browser is expecting for setting that input (to_json doesn't match that format)
Therefore, in your case of wanting to set DateTime.current it should be something along the lines of
fill_in 'id/name/label of input', with: DateTime.current.strftime("%m%d%Y\t%I%M%P")
If that doesn't work for you then most likely you're not actually attempting to fill a visible <input type="datetime-local"> field (maybe you're using some kind of JS widget that replaces/hides the input???) and you'll need to specify the exact HTML you are trying to fill in your question.
from what I understand, you need to fill in a string representation of the datetime format
examples of such dates are
1990-12-31T23:59:60Z
or
1996-12-19T16:39:57-08:00
so something like
fill_in datetimeinput, with: "1990-12-31T23:59:60Z"
should work (hope so!)

Asp.Net MVC: Client data validation in double, with localization

I've a small problem with my Asp.Net MVC.
For now I've developed a website in english, everything is working fine, all my texts are already in localization, and I've already a session based system. When I go to another language(in my case french), it changes the Thread.CurrentThread.CurrentUICulture and Thread.CurrentThread.CurrentCulture to a culture info created from "fr".
All my traductions is working, but I've a problem in one form.
In France, the decimal part is separated from the integer part with ",". The server validation works fine with it and translate "234,512"(and know transforms "234.512" too)into a double.
But the client validation doesn't accept this, it says:
"Le champ XYZ doit ĂȘtre un nombre."
So it has the correct local(because the message is translated in french), but it seems to want the number edited in "235,55".
At start I thought it wasn't a big deal, users can enter number with the "234.512" format, but the problem is for the edition of data, since the thread is in French, it fill the model with "234,512", and not "234.512", and because of that customer must change the separator on every change(event if they don't make change on this field) otherwise they get a client validation error(no call are being made when I press on the submit button, I checked several times).
So what should I do to have the client validation script for double working in the current locale?
Thank you very much!
It seems to be a problem with the jquery.validate.js (or jquery.validate.unobtrusive.js), which only accepts dots as separators.
Take a look on the following post for a solution:
http://www.mfranc.com/2011/07/05/jquery-valdiator-modyfing-decimal-separator/
or
http://www.campusmvp.net/asp-net-mvc-3-and-the-coma-in-decimals/
It is known problem. Javascript validators inside jquery doesn't allow anything except point.
The simplest way is to change jquery.validate.min.js (or so) or override custom validator inside your cshtml. Inside jquery it will be:
// http://docs.jquery.com/Plugins/Validation/Methods/number
number: function(value, element) {
//return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(value); <-- original
return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:[\.,]\d+)?$/.test(value);
},

MVC 4 Tutorial validation errors

I'm following the MVC 4 tutorial and I'm having some trouble with decimals and date validations.
When I try to insert a date in format dd-MM-yyyy (because it is the format defined in the Culture I have my pc in) it returns this error: The field ReleaseDate must be a date.
Also when trying to insert a decimal field like 3,01 it returns a validation message: The field xpto must be a number.
You will probably say in these case to use a dot for this but in the culture i'm using that is the thousands separator like 1.000
Is this a general problem or it is just me?
Thanks in advance for your help.
By "My PC" I assume you mean client side, the browser validation fails? See my article http://msdn.microsoft.com/en-us/library/gg674880(VS.98).aspx - jQuery moved the local specific files so you will have to hunt for them. For debugging 1. disable client side validation and verify server validation works with your local (ie, decimals and dates in your local). Then it's a matter of getting the correct client side validation. This is not really an MVC question, it's more of a "jQuery non-english date/time & decimal validation" type question. You might have to post this question again. Once you solve this, please post your solution.
To solve this quickly, create the simplest possible HTML page with jQuery validation that fails, then post the repro. You can look at the generated HTML from MVC to help you create a simple HTML page.
You can change this behavior by setting the input culture: http://msdn.microsoft.com/en-us/library/bz9tc508.aspx. You can fix it on a specific culture or use 'auto' so the browser will use the user's current culture.

Resources