w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to think about a database design when users have different amounts of input
You are in the right track and you could probably add Users Table and change your Workout Table to UsersWorkout Table and create a relationship between the two. And then you could probably change your Exercise table to WorkoutExercise Table and create a separate Table for Exercise that has the type of Exercises (e.g. Bench, Deadlift). See my attached ERD below from MS Access: And below are Sample Data for each table: Users User's Workouts Workout's Exercises And finally Exercises These are Normalized tables by the way to prevent redundancy and prevent UPDATE, DELETE, INSERT anomalies.

Categories : Database

PayPal NVP API Error 10413 - The totals of the cart item amounts do not match order amounts
Change L_PAYMENTREQUEST_0_TAXAMT0 to 4.00 since you have qty=2 of this line item. METHOD=SetExpressCheckout CANCELURL=http://vikingchallenge/site/payPalCancel RETURNURL=http://vikingchallenge/site/payPalReturn MAXAMT=48.00 REQCONFIRMSHIPPING=0 NOSHIPPING=1 LOCALECODE=GB PAYMENTREQUEST_0_AMT=48.00 PAYMENTREQUEST_0_CURRENCYCODE=GBP PAYMENTREQUEST_0_PAYMENTACTION=SALE PAYMENTREQUEST_0_ITEMAMT=40 PAYMENTREQUEST_0_TAXAMT=8.00 PAYMENTREQUEST_0_DESC=Adults PAYMENTREQUEST_0_ALLOWEDPAYMENTMETHOD=InstantPaymentOnly L_PAYMENTREQUEST_0_NAME0=Adults L_PAYMENTREQUEST_0_DESC0=Adults L_PAYMENTREQUEST_0_AMT0=20 L_PAYMENTREQUEST_0_TAXAMT0=4.00 L_PAYMENTREQUEST_0_QTY0=2

Categories : PHP

paypal expresscheckout in oscommerce get this error The totals of the cart item amounts do not match order amounts
PAYMENTREQUEST_0_CURRENCYCODE=CAD &L_PAYMENTREQUEST_0_NAME0=test &L_PAYMENTREQUEST_0_NUMBER0= &L_PAYMENTREQUEST_0_AMT0=125.00 &L_PAYMENTREQUEST_0_QTY0=1 &PAYMENTREQUEST_0_ITEMAMT=125.00 &PAYMENTREQUEST_0_TAXAMT=0.00 &PAYMENTREQUEST_0_SHIPPINGAMT=0.00 &PAYMENTREQUEST_0_SHIPDISCAMT=0.00 &PAYMENTREQUEST_0_HANDLINGAMT=12.50 &PAYMENTREQUEST_0_AMT=137.50

Categories : Misc

How to make an input field only take feasible dollar amounts
Bind this function to the onchange event of your text field. This will parse the value of the field as a float and remove any number after 2 decimals. You can also use input type="number" to prevent strings as input. Needless to say, this will require server-side validation. The user can disable Javascript and input type fairly easily: never expect this to work if these data will get back to your server. function check(e){ e.value = parseFloat(e.value).toFixed(2) } working jsfiddle: here. input: 123456 - result: 123.456 input: 12,3456 - result: 12,34

Categories : Javascript

Using AppleScript to Input large amounts of dates into Mac Calendar
I solved the date parsing issue on my system by changing the external file format to: 5 September 2013 This could be a local system date format setting, as that is how mine is defined in the Language & Text - System Preference. Explore your settings first perhaps. I've reworked your script a bit below to show you how to get at the event name by changing the loop to an index based one. Also i've dropped the tell "Finder" block as it is not needed, you were not using any commands from the Finder in this case. I also renamed some of your variables to be more legible (subjective), other tweaks are commented in the script. set cal_data to the paragraphs of (read (choose file with prompt "Pick text file containing track names")) set c to the count of cal_data repeat with i from 1 to

Categories : Osx

How to present massive amounts of repeated data to user
To limit the number of queries to the SQL Database, a good solution is to try group to group your multiple requests in one. An example : /* I'm supposing that $gardeners looks like that : * { * bob : { * tools: [{Id: 117,name: "Rake"}, {Id: 175,name: "Shovel"},[...]], * fruits : [...] * }, * Lisa : {tools: [...]} * } */ $toolIDs = array(); foreach ($gardeners as $gardener) { foreach ($gardener->tools as $tool) { $toolIDs[] = $tool->Id; // get Ids of all used tools } } $toolIDs = array_unique($toolIDs); // remove duplicate Ids // fetch the description of all the used tools in one go $result = mysqli_query(sprintf("SELECT id, description FROM tools WHERE id IN ('%d');", implode("','", $toolID))); Since we have a id-description couple, we can construct an arr

Categories : PHP

parsing a csv file $INPUT, write to $OUTPUT, and prompt for user input all in a while loop - user NOT prompted
I solved my own issue here. I found out that read by default is reading from the stdin. When I was trying to prompt for input it was using stdin, so the lines I was reading were technically the stdin input. If you want to read a file in a while loop with the method I have done you have to change the fd like so: while read -u 6 column1 column2 do .....body done 6< $INPUTFILE Key being the "6" which could be any arbitrary number.

Categories : Bash

IE9 Confirmation Dialog not waiting for user input , postback happening without user input
Your dialog is kind of async, as the function Confirmation returns immediately. So, you cannot return whether the user will click yes or no right away. I'd suggest the following: Make your ASP runat="server" Button invisible (display:none;) Put a new, client side button to the same place on click of the client side button, call Confirmation As a call back of selecting yes in the dialog, trigger a click to the invisible ASP button This is probably the easiest way to have programmatic control of when the postback happens, without the user being able to call the postback directly. Triggering the postback on selecting Yes would then look like this: buttons['Yes'] = function() { $(this).dialog('close'); var result = $(source).attr('tag'); $('#<%=hidField.ClientID%>').va

Categories : Javascript

how do you make a text input field open different links based on user input
Pseudocode: function parmatch(input): if input matches /^bbb$/ open 'http://example1.com/{input}' return if input matches /zzz/ open 'http://example2.com/something-predefined{input}' return if input matches /xxx/ open 'http://example3.com/something-predefined{input}' return MDN's article on regular expressions in JavaScript

Categories : Javascript

How to restrict user input character length of HTML5 input type="number"?
I don't know my answer is useful for you? But i happy if i can help you. you should write a js method and then use it in your html page. function limit(element) { var max_chars = 2; if(element.value.length > max_chars) { element.value = element.value.substr(0, max_chars); } } <input type="number" onkey ="limit(this);" onkeyup="limit(this);">

Categories : Jquery

How can I make my program stop reading user input when no input is given?
instead of for, do: string input = Console.ReadLine(); while(input != String.Empty) { //do things input = Console.ReadLine(); } if you're trying to allow any number of inputs. Or if(input == "") break; if you want the for loop

Categories : C#

Pass One Input Value Into Input Type Hidden Value When User Submits
I would first suggest you give your HTML some IDs like so: <form id="signup" method="post" action="https://go.reachmail.net/libraries/form_wizard/process_subscribe.asp" > <input type='text' name='rm_accounts' id='rm_accounts' value='' /> <input type="hidden" name="page_confirm" id="page_confirm" value="http://www.mywebsite.com/index.php?rm_accounts="> <input type="submit" name="Submit" value="Submit" > </form> Then use some jQuery for your task: $('#signup').submit(function(){ var value = $('#rm_accounts').val(); var page_confirm = 'http://www.mywebsite.com/index.php?rm_accounts='+value; $('#page_confirm').val(page_confirm); });

Categories : PHP

Checking For user input between certain limit if not asking again until correct input is entered
You did not allocate memory to hold x and y. Allocate them on the stack and then use the & address of operator to obtain a pointer to that memory. #include <stdio.h> int limitChecker(int x, int y, int input); int main(void) { int x; int y; printf("Enter the width of the windows. (3 - 5) : "); scanf("%d", &x); x = limitChecker(3, 5, x); printf("width: %d ", x); printf("Enter the height of the windows. (2 - 4) : "); scanf("%d", &y); y = limitChecker(2, 4, y); printf("Height: %d ", y); } int limitChecker(int x, int y, int input) { while(!(input>=x && input<=y)) { printf("Please enter a value between (%d - %d): ",x,y); scanf("%d", &input); } return input; } If you want x and y to be poi

Categories : C

How to remove extra digits from user input in currency and how to check if the user entered nothing in asp.net c#?
Try to use regular expressions and look for a pattern of XX.XX , if the input is wrong, then the user must fix the input. private void button1_Click(object sender, EventArgs e) { var pattern = @"^[0-9]*(.[0-9]{1,2})?$"; if(Regex.IsMatch(textBox1.Text, pattern)) MessageBox.Show("Correct Input."); else MessageBox.Show("Wrong Input!"); } Regular Expression

Categories : C#

How to prompt user for input and use input else where in batch file
set /p "SourcePath=Enter directory path containing files to be converted: " echo %SourcePath% set /p "TargetPath=Enter directory path to save files to once converted: " echo %TargetPath% pause

Categories : Batch File

Persist text in html input during user input
Just change if (text.indexOf("$") == -1){ text = "$ " +text; } to if (text.indexOf("$") == -1){ text = "$ " +text; } if (!(test.indexOf("USD") >= 0)){ text = text + " USD"; }

Categories : Jquery

Let OneToOneField to User only render one text input (for User.first_name) using a ModelForm
I rewrote the question and adapted the code. The answer can be found here.

Categories : Django

Reusing returned user inputted value from class without re-requesting input from user
You're calling the method that asks the user for their username. Instead, create a private field in your StaffLogin2 class like this: private String username and set it with the returned value from the user like this: public void username() { this.username = JOptionPane.showInputDialog("Enter Username:"); } Then, reference this field elsewhere with by calling the following getter method, which should be in your StaffLogin2 class: public String getUsername() { return username; } One other thing - if you're intending this app to be used by more than one person at a time, you'll want to lose the "static" modifiers on your methods and instantiate a class. Probably a better practice for something like this anyway.

Categories : Java

User Input with document.getElementById from an input box
A few problems there. getElementById returns a DOM element. You need to grab the value of the element, which is a string, and then convert it to a number (or cast it): var pr = +document.getElementById("P").value; var ra = +document.getElementById("r").value; var ti = +document.getElementById("t").value; + casts the string to a number. Now your multiplication should work. Also you forgot your quotes around the function call on the onclick event. Oh and read on why document.write is bad practice. Edit: As Bergi said, multiplication casts a number as well, but in any case since you have variables, you probably want numbers assigned to them.

Categories : Javascript

Linux terminal input: reading user input from terminal truncating lines at 4095 character limit
I do not have a workaround for you, but I can answer question 2. In linux PIPE_BUF is set to 4096 (in limits.h) If you do a write of more than 4096 to a pipe it will be truncated. From /usr/include/linux/limits.h: #ifndef _LINUX_LIMITS_H #define _LINUX_LIMITS_H #define NR_OPEN 1024 #define NGROUPS_MAX 65536 /* supplemental group IDs are available */ #define ARG_MAX 131072 /* # bytes of args + environ for exec() */ #define LINK_MAX 127 /* # links a file may have */ #define MAX_CANON 255 /* size of the canonical input queue */ #define MAX_INPUT 255 /* size of the type-ahead buffer */ #define NAME_MAX 255 /* # chars in a file name */ #define PATH_MAX 4096 /* # chars in a path name including nul */ #define PIPE_BUF

Categories : Linux

In C, I wrote a program to call an exe using system(). The exe asks for user input. How can I make my program provide the input?
Instead of using system, you probably want to use popen (or, in Microsoft-land, _popen). This lets you open the child program and gives you a FILE * through which you can read the child's standard output, or write to the child' standard input (depending on whether you specify "r" or "w" as the open mode). Although non-standard, some reasonably recent versions allow both reading and writing (which it sounds like you'd really prefer). If you can't do the latter, since you seem to be doing this on Windows, you can/could use CreateProcess to create the child with both input and output redirected. It's much more versatile, but also a lot more work.

Categories : C

scan jtextfield for input, write in textfile, scan again for new input until user closes the panel
When you construct a FileOutputStream by only passing in the file, by default, it does not append. What you need to do to make sure it appends is do new FileOutputStream(file, true); Also, I haven't tested your code but it appears you are closing the streams while only declaring and initializing your streams only once, so next time you try to write it will fail because the streams are closed. Try replacing the close() with a flush() instead and add a WindowListener to your JFrame. You may then close your streams on windowClosing. From what I can tell, you need to make your streams global declarations.

Categories : Java

Verifying user input for a magic square game/Comparing arrays (user-defined&programmer-defined)
IMO you should maintain a multi-dimensional array for better code readability that is int[3][3] instead of 3 int[3]'s. Below is my try public static void main(String [] args) { int[][] input=new int[3][3]; int[][] defined={{8,1,6}, {3,5,7}, {4,9,2}}; Scanner sc=new Scanner(System.in); //Take input //Outer loop for(int i=0; i<3; i++) { System.out.println("Enter value for Row number - "+(i+1)); //Inner loop for(int j=0; j<3; j++) { input[i][j] = sc.nextInt(); } } //Compare boolean matches = true; for(int i=0; i<3; i++) { //Inner loop for(int j=0; j<3; j++) { if(input[i][j] != defined[i][j]) { matches = false; break; }

Categories : Java

zsh - read user input with default value - empty input not empty?
A case is better when you want to consider many different values and a default one function is_confirmed { read -rs -k 1 ans case "${ans}" in y|Y|$' ') printf "Yes " return 0 ;; *) # This is the default printf "No " return 1 esac }

Categories : Osx

input from user
Yes, every input is string. But just try: a = int(a) b = int(b) before your code. But be aware of the fact, that user can pass any string he likes with raw_input. The safe method is try/except block. try: a = int(a) b = int(b) except ValueError: raise Exception("Please, insert a number") #or any other handling So it could be like: try: a = int(a) b = int(b) except ValueError: raise Exception("Please, insert a number") #or any other handling c=a+b d=a-b p=a*b print "sum =", c print "difference = ", d print "product = ", p From the documentaion: The function then reads a line from input, converts it to a string (stripping a trailing newline), and returns that.

Categories : Python

Sanitizing User Input
You could always use regular expressions to construct an accepted pattern and remove the cases that don't match. I'd try that to be in full control. Don't know of any ready made checks.

Categories : SQL

Get user input from Speech?
It does not look like in your situation e.Result.Text represents something that you can enumerate: you are checking the words that start the text, not the text in its entirety. In cases like this, you should not use a switch, and go for a chain of if-then-elses instead: var text = e.Result.Text; if (text.StartsWith("test")) { writeConsolas("What do you want me to test?", me); } else if (text.StartsWith("change username")) { writeConsolas("What do you want to be called?", me); } else if (text.StartsWith("exit")) { writeConsolas("Do you wish me to exit?", me); } else if (text.StartsWith("call me")) { // Here you have the whole text. Chop off the "call me" part, // using Substring(), and do whatever you need to do with the rest of it } else ...

Categories : C#

Take user input from the background
Well you can have your server read a FIFO or a unix domain socket (or even a message queue). Then write a client that takes command line input and writes it to the pipe/queue from some other terminal session. With FIFOs you can just echo input from the command line itself to the pipe but FIFOs come with their own headaches. The "push the button and magic happens" is a lot trickier but maybe that was badly phrased?

Categories : Linux

GTK : wait for user input
#include <gtk/gtk.h> static void on_button_clicked(GtkButton *button,gpointer data); static void on_entry_activate(GtkEntry *entry,gpointer data); int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *entry; GtkWidget *button; GtkWidget *hbox; gtk_init(&argc,&argv); window=gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window),"entry"); gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER); gtk_container_set_border_width(GTK_CONTAINER(window),5); hbox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); gtk_container_add(GTK_CONTAINER(window),hbox); entry=gtk_entry_new(); gtk_box_pack_start(GTK_BOX(hbox),entry,TRUE,TRUE,5); button=gtk_button_new_with_label("Ok"); gtk_box_pack_sta

Categories : C

C# 2D array from user input
You can use nested for-loops. //For 25 players. int Row = 5; int Column = 5; string PlayerData[column][row]; for (int i=0;i<Column;i++) { for (int j=0;j<Row;j++) { Console.WriteLine("Please add the players name: "); Playername = Console.Readline(); PlayerData[i][j]=playername // Add more prompts and attributes here. } } I recommend you get a beginner's book to programming. If this solves your problem don't forget to mark the answer and up-vote other answers or questions that you help you. Welcome to SO.

Categories : C#

User Input, UTF-8 and XML Support
You should be using an XML library/application to handle the following: Those records are then pulled by a cron job and put into an xml file for another application to use Otherwise you're going to have to cater for all the escapable XML entities and look after character encoding etc. The user should be able to enter these characters, and the XML creation mechanism will be able to escape these automatically. As such, I don't think this is a validation issue. Check out this SO question re. XML creation via Ruby.

Categories : Ruby On Rails

Trying to put user input in yahoo api URL
You can enter/add/put value from user input by %@ sign, such like NSString *urlString = [NSString stringWithFormat:@"http://query.yahooapis.com/userInput=%@",textFiled.text]; And also use stringByAddingPercentEscapesUsingEncoding for convert your URL to legal URL NSString *urlString = [NSString stringWithFormat:@"URL_STRING"]; NSURL *myUrl = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

Categories : Iphone

dat.GUI user input not working
The z order might be becoming wrong? I can't find anything easier to use than dat gui. .main { z-index: 5; } Would make sure this element is at the front. Other than that I'm sure what the problem might be.

Categories : Javascript

Try catch and user input
Use something like: Scanner in = new Scanner(System.in); int userIn = -1; try { userIn = in.nextInt(); } catch (InputMismatchException a) { System.out.print("Problem"); } switch(userIn){ case -1: //You didn't have a valid input break; By having something like -1 as the default value (it can be anything that you won't receive as input in the normal run, you can check if you had an exception or not. If all ints are valid, then use a boolean flag which you can set in the try-catch blocks.

Categories : Java

if there is str('a') or str('b') or str('c') in a user input then do somthing
It is, but what you wrote does something entirely different. It checks to see if str('a') is truthy, if 'b' is truthy, or if 'c' is in input. While Python is very readable, it doesn't make assumptions about what you write. You have to be explicit: if 'a' in input or 'b' in input or 'c' in input: ... Or: strings = ('a', 'b', 'c') if any(s in input for s in strings): ... Calling str() with a string argument is pointless. Also, input is the name of a builtin, so I suggest you rename your variable.

Categories : Python

User input in Node.js
Prompt is asynchronous, so you have to use it asynchronously. var prompt = require('prompt') , arr = []; function getAnother() { prompt.get('number', function(err, result) { if (err) done(); else { arr.push(parseInt(result.number, 10)); getAnother(); } }) } function done() { console.log(arr); } prompt.start(); getAnother(); This will push numbers to arr until you press Ctrl+C, at which point done will be called.

Categories : Javascript

read an input key from user
private void AddStudent_KeyDown(object sender, KeyEventArgs e) { if(e.KeyCode == Keys.F1) { // do your stuff } } Then in your constructor add the following: public AddStudent() { InitializeComponent(); this.KeyDown +=new System.Windows.Forms.KeyEventHandler(AddStudent_KeyDown); }

Categories : C#

Take input from the user using java
Your first code snippet: Scanner in = new Scanner(System.in); System.out.println("Enter a string"); String s = in.nextLine(); System.out.println("You entered string " + s); does work. I'm guessing because you reassigned standard output stream using System.setOut you no longer see the output printed from System.out.println Try creating a thread that prints your new console outputstream into a file or somewhere and you will see the output

Categories : Java

Get mm dd yyyy from user input
Another way to do this sort of thing is to simply read the entire string at once, then use the POSIX standard function strptime() to convert it to a broken-down struct containing the parts. Like this: string in; cin >> in; // TODO: check return value struct tm out = {}; strptime(in.c_str(), "%m/%d/%Y", &result); // TODO: check return value cout << out.tm_mon+1 << endl << out.tm_mday << endl << out.tm_year+1900 << endl; Note that the fields in struct tm have "strange" semantics--that's why the integer offsets are applied like that. Oh well, chalk that one up to history. Now not only can you print the parts, you can pass the struct to other functions like strftime, mktime, etc.

Categories : C++

Query regarding getting input from user in C
If the input is 123, then on each iteration of the loop, it calculates: n = 0 * 10 + ('1' - '0'); n = 1 * 10 + ('2' - '0'); n = 12 * 10 + ('3' - '0'); assert(n == 123); The character codes for the digits are always consecutive, so '1' - '0' is 1, etc. It converts the digits of a number into a number. Get used to the idiom; you will see it a lot in C code. The code shown is sloppy in a variety of ways: int readuint() { int n = 0; char c = fgetc(stdin); do { n = n * 10 + (c - '0'); } while ((c = fgetc(stdin)) != ' '); return n; } The name indicates it is reading an unsigned integer (uint), but the type used is a signed int. The type of c should be int because fgetc() (and getc() and getchar()) return an int and not a char. There's no way to indicate

Categories : C



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.