Search Results

Search found 1491 results on 60 pages for 'inputs'.

Page 51/60 | < Previous Page | 47 48 49 50 51 52 53 54 55 56 57 58  | Next Page >

  • PHP: parse $_FILES[] data in multidimesional array

    - by superUntitled
    I having been looking around for an answer to this and have not found an answer anywhere, I am hoping someone has done this before! I have a form that allows for dynamic duplication of the form fields. The form allows for file uploads and text input, so the data is sent in both $_POST and $_FILES arrays. The the initial set of inputs look like this: <input type="text" name="primary[1][text]" /> <input type="file" name="primary[1][file]" /> <input type="text" class="a" name="secondary[1][text][]" /> <input type="file" name="secondary[1][file][]" /> When duplicated the fields are incremented, they look like this: <input type="text" name="primary[2][text]" /> <input type="file" name="primary[2][file]" /> <input type="text" class="a" name="secondary[2][text][]" /> <input type="file" name="secondary[2][file][]" /> To complicate matters, the "secondary" form fields can also be duplicated (thus the [] at the end of the secondary name array. How can I parse the posted $_FILES array? I have tried something like this: foreach ($_FILES['question'] as $f_num) { echo $f['file']['name']; } but I get an "Undefined index: file... " error.

    Read the article

  • How to check user input for correct formatting

    - by Arcadian
    This is what i've come up with so far private void CheckFormatting() { StringReader objReaderf = new StringReader(txtInput.Text); List<String> formatTextList = new List<String>(); do { formatTextList.Add(objReaderf.ReadLine()); } while (objReaderf.Peek() != -1); objReaderf.Close(); for (int i = 0; i < formatTextList.Count; i++) { } } What it is designed to do is check that the user has entered their information in this format Gxx:xx:xx:xx JGxx where "x" can be any integer. As you can see the user inputs their data into a multi-line textbox. i then take that data and enter it into a list. the next part is where i'm stuck. i create a for loop to go through the list line by line, but i guess i will also need to go through each line character by character. How do i do this? or is there a faster way of doing it? thanks in advance

    Read the article

  • PHP: parse $_FILES[] data in multidimesional array

    - by superUntitled
    Example form here: http://jsfiddle.net/superuntitled/uaTtx/1/ I have a form that allows for dynamic duplication of the form fields. The form allows for file uploads and text input, so the data is sent in both $_POST and $_FILES arrays. The the initial set of inputs look like this: <input type="text" name="question[1][text]" /> <input type="file" name="question[1][file]" /> <input type="text" class="a" name="answer[1][text][]" /> <input type="file" name="answer[1][file][]" /> When duplicated the fields are incremented, they look like this: <input type="text" name="question[2][text]" /> <input type="file" name="question[2][file]" /> <input type="text" class="a" name="answer[2][text][]" /> <input type="file" name="answer[2][file][]" /> To complicate matters, the "answer" form fields can also be duplicated (thus the [] at the end of the 'answer' name array. How can I parse the posted $_FILES array? I have tried something like this: foreach ($_FILES['question'] as $p_num) { echo $p_num['file']['name']; foreach ($_FILES['answer'] as $a_num) { echo $a_num['file']['name']; } } but I get an "Undefined index: file... " error. How can I parse out the posted values.

    Read the article

  • How to make a plot from summaryRprof?

    - by ThorDivDev
    This is a question for an university assignment. I was given three algorithms to calculate the GCD that I already did. My problem is getting the Rprof results to a plot so I can compare them side by side. From what little understanding I have about Rprof, summaryRprof and plot is that Rprof is used like this: Rprof() #To start #functions here Rprof(NULL) #TO end summaryRprof() # to print results I understand that plot has many different types of inputs, x and y values and something called a data frame which I assume is a fancy word for table. and to draw different lines and things I need to use this: http://www.harding.edu/fmccown/r/ what I cant figure out is how to get the summaryRprof results to the plot() function. > Rprof(filename="RProfOut2.out", interval=0.0001) > gcdBruteForce(10000, 33) [1] 1 > gcdEuclid(10000, 33) [1] 1 > gcdPrimeFact(10000, 33) [1] 1 > Rprof(NULL) > summaryRprof() ?????plot???? I have been reading on stack overflow that and other sites that I can also try to use profr and proftools although I am not very clear on the usage. The only graph I have been able to make is one using plot(system.time(gcdFunction(10,100))) As always any help is appreciated.

    Read the article

  • Hashing Function for Map C++

    - by Josh
    I am trying to determine a hash function which takes an input (i, k) and determines a unique solution. The possible inputs for (i, k) range from 0 to 100. Consider each (i, k) as a position of a node in a trinomial tree. Ex: (0, 0) can diverge to (1, 1) (1, 0) (1, -1). (1, 1) can diverge to (2, 2) (2, 1) (2, 0). Sample given here: http://www.google.com/imgres?imgurl=http://sfb649.wiwi.hu-berlin.de/fedc_homepage/xplore/tutorials/stfhtmlimg1156.gif&imgrefurl=http://sfb649.wiwi.hu-berlin.de/fedc_homepage/xplore/tutorials/stfhtmlnode41.html&h=413&w=416&sz=4&tbnid=OegDZu-yeVitZM:&tbnh=90&tbnw=91&zoom=1&usg=__9uQWDNYNLV14YioWWbrqPgfa3DQ=&docid=2hhitNyRWjI_DM&hl=en&sa=X&ei=xAfFUIbyG8nzyAHv2YDICg&ved=0CDsQ9QEwAQ I am using a map map <double, double> hash_table I need a key value to be determined from pairs (i, k) to hash to to value for that (i, k) So far I was only able to come up with linear functions such as: double Hash_function(int i, int k) { //double val = pow(i, k) + i; //return (val % 4294967296); return (i*3.1415 + k*i*9.12341); } However, I cannot determine a unique key with a certain (i, k). What kind of functions can I use to help me do so?

    Read the article

  • How to best manage multi-frame MovieClips with classes?

    - by Arms
    After switching to AS3, I've been having a hell of a time figuring out the best way to manage MovieClips that have UI elements spread across multiple frames with a single class. An example that I am working on now is a simple email form. I have a MovieClip with two frames: the 1st frame has the form elements (text inputs, submit button) the 2nd frame has a "thank you" message and a button to go back to the first frame (to send another email) In the library I have linked the MovieClip to a custom class (Emailer). My immediate problem is how do I assign a MouseEvent.CLICK event to the button on the 2nd frame? I should note at this point that I am trying to avoid putting code on the timeline (except for stop() calls). This is how I am 'solving' the problem now: Emailer registers an event listener for a frame change ( addEventListener("frame 2", onFrameChange) ) On the 2nd frame of the MovieClip I am calling dispatchEvent(new Event("frame 2")); (I would prefer to not have this code on the frame, but I don't know what else to do) My two complaints with this method are that, first I have calls to addEventListener spread out across different class methods (I would rather have all UI event listeners registered in one method), and second that I have to dispatch those custom "onFrameChange" events. The second complaint grows exponentially for MovieClips that have more than just 2 frames. My so called solution feels makes me feel dirty and makes my brain hurt. I am looking for any advice on what to do differently. Perhaps there's a design pattern I should be looking at? Should I swallow my pride and write timeline code even though the rest of my application is written in class files (and I abhor the Flash IDE code editor)? I absolutely LOVE the event system, and have no problem coding applications with it, but I feel like I'm stuck thinking in terms of AS2 when working with mutl-frame movieclips and code. Any and all help would be greatly appreciated.

    Read the article

  • How do I obtain selected rows in a DataGridView from different pages

    - by cmrhema
    Hi, I have a windows forms DataGridView, where I have data and a checkbox for each row. I will select check box for a particular row and all the selected rows will be populated in another page. if (grdEmp.Rows.Count > 0) { var selectedEmpIDs= from DataGridViewRow coll in grdEmp.Rows where Convert.ToBoolean(coll.Cells["Select"].Value) == true select coll; if (selectedEmpIDs.Count() > 0) { foreach (DataGridViewRow row in selectedEmpIDs) { selectedEmp+= row.Cells["EmpId"].Value + ","; } } } This works good only for one page. When I navigate to another page, and click the selected rows, the previous one goes off. How do I resolve it. Thanks cmrhema Note :Sorry for the confusion, When I meant it works good for a page, I meant paging. I think I need to add more inputs, There are 10 pages in the gridview. I select the first record from each page of the gridview, one after another by clicking next page( Page next button). But only the record that was selected the last is getting displayed and others and ignored off. What could be the prblm

    Read the article

  • Fatal error: Call to a member function escape() on a non-object in .....on line 10

    - by danyo
    i am making a simple javascript login form for wordpress. i have the form submitting to the following bit of php to handle the login: <?php get_header(); global $user_ID; if (!$user_ID) { if($_POST){ //We shall SQL escape all inputs $username = $wpdb->escape($_REQUEST['username']); $password = $wpdb->escape($_REQUEST['password']); $remember = $wpdb->escape($_REQUEST['rememberme']); if($remember) $remember = "true"; else $remember = "false"; $login_data = array(); $login_data['user_login'] = $username; $login_data['user_password'] = $password; $login_data['remember'] = $remember; $user_verify = wp_signon( $login_data, false ); //wp_signon is a wordpress function which authenticates a user. It accepts user info parameters as an array. if ( is_wp_error($user_verify) ) { echo "<span class='error'>Invalid username or password. Please try again!</span>"; exit(); } else { echo "<script type='text/javascript'>window.location='". get_bloginfo('url') ."'</script>"; exit(); } } else { //get_header(); ?> any ideas on why i am getting the error? Cheers, Dan

    Read the article

  • java script is not working in mozila

    - by Piyush
    I have added some javascript in html page for input validation.same page is working correct in IE and chrome but in mozila its not working.The problem is when user inputs invalid data its supposed to show alert msg box and when user clicks OK it should return false to form...BUT mozila is not waiting for alert box it just shows alert box for 5-6 sec and then goes to next page defined in form action="nextpage.php" function validate_form(thisform) { with (thisform) { if (validate_required(oldpassword, "<b>Error: </b>Please enter the Old Password!") == false) { changeColor("oldpassword"); return false; } else if (valid_length(newpassword, "<b>Error: </b>Please enter the New Password!!") == false) {newpassword.value=""; changeColor("newpassword"); return false; } else if (valid_length(cnfpassword, "<b>Error: </b>Please enter the Confirm Password!!") == false) {cnfpassword.value=""; changeColor("cnfpassword"); return false; } else if (document.getElementById('newpassword').value != document.getElementById('cnfpassword').value) {changeColor("newpassword");cool.error("<b>Error: </b>Passwords entered are not same!"); newpassword.value="";cnfpassword.value="";return false;} } }function validate_required(field, alerttxt) { with (field) { if (value == null || value == "") { cool.error(alerttxt);return false; } else { return true; } } } cool.error is nothing but CSS nd Js for alert box.I thing there is not any problem in my code weather problem is in some browser settings.Is it so??? because it is working fine in IE and Chrome.

    Read the article

  • Getting the value of an input inside a td for each row with jQuery

    - by Anne
    I am still having so many problems with this: function padTitles() { $('tr').each(function () { var tds = $(this).find('input'), text = tds.filter('[id^="TempRowKey_"]').val(), tdToPad = tds.filter('[id^="title_"]'), pad; if (/0\.0$/.test(text)) pad = 10; else if (/\.0$/.test(text)) pad = 35; else pad = 60; tdToPad.css('paddingLeft', pad); }); } Note: here is what I was using before. This worked when the value was not inside an input: var tds = $(this).find('td'), text = tds.filter('[id^="refKey_"]').text(), It is supposed to get the Value of the Inputs with id's that start with TempRowKey_ and then use these for padding. But the code does nothing. Here is my HTML: <tr id="row_1"> <td id="tempRowKey_1" > <input type="text" size="10" value="1.0.0" class="updatable" id="TempRowKey_1"> </td> <td id="title_1"> <input id="Title_1" class="updatable" type="text" value="zxxx" size="100" name="item.Title"> </td>. <td ... </tr> Is there some way I can test this. I can't get access to anything inside the jQuery block?

    Read the article

  • new to lists on python

    - by user1762229
    This is my current code: while True: try: mylist = [0] * 7 for x in range(7): sales = float(input("Sales for day:")) mylist[x] = sales if sales < 0: print ("Sorry,invalid. Try again.") except: print ("Sorry, invalid. Try again.") else: break print (mylist) best = max(sales) worst = min(sales) print ("Your best day had", best, "in sales.") print ("Your worst day had", worst, "in sales.") When I run it I get this: Sales for day:-5 Sorry,invalid. Try again. Sales for day:-6 Sorry,invalid. Try again. Sales for day:-7 Sorry,invalid. Try again. Sales for day:-8 Sorry,invalid. Try again. Sales for day:-9 Sorry,invalid. Try again. Sales for day:-2 Sorry,invalid. Try again. Sales for day:-5 Sorry,invalid. Try again. [-5.0, -6.0, -7.0, -8.0, -9.0, -2.0, -5.0] Traceback (most recent call last): File "C:/Users/Si Hong/Desktop/HuangSiHong_assign9_part.py", line 45, in <module> best = max(sales) TypeError: 'float' object is not iterable I am not quite sure how to code it so that, the lists do NOT take in negative values, because I only want values 0 or greater. I am not sure how to solve the TypeError issue so that the min and max values will print as in my code My last issue is, if I want to find the average value of the seven inputs that an user puts in, how should I go about this in pulling the values out of the lists Thank you so much

    Read the article

  • iPhone producing strange results on 'if' statement

    - by Rob
    I have a UIPicker where the user inputs a specified time (i.e. 13:00, 13:01, 13:02, etc.) - which determines their score. Once they hit the button an alert comes up with the score that is determined through this 'if-else' statement. Everything seems to work great MOST of the time - but I am getting some erratic behavior. This is the code: //Gets my value from the UIPicker and then converts it into a format that can be used in the 'if' statement. NSInteger runRow = [runTimePicker selectedRowInComponent:2]; NSString *runSelected = [runTimePickerData objectAtIndex:runRow]; NSString *runSelectedFixed = [runSelected stringByReplacingOccurrencesOfString:@":" withString:@"."]; //The actual 'if' statment. if ([runSelectedFixed floatValue] <= 13.00) { runScore = 100; } else if ([runSelectedFixed floatValue] <= 13.06) { runScore = 99; } else if ([runSelectedFixed floatValue] <= 13.12) { runScore = 97; } else if ([runSelectedFixed floatValue] <= 13.18) { runScore = 96; } else if ([runSelectedFixed floatValue] <= 13.24) { runScore = 94; } else if ([runSelectedFixed floatValue] <= 13.30) { runScore = 93; } else if ([runSelectedFixed floatValue] <= 13.36) { runScore = 92; } else if ([runSelectedFixed floatValue] <= 13.42) { runScore = 90; } else if ([runSelectedFixed floatValue] <= 13.48) { runScore = 89; } else if ([runSelectedFixed floatValue] <= 13.54) { runScore = 88; } Now, when I test the program, I will get the expected result when I choose '13:00' which is '100'. I also get the expected result of '99' when I choose all of the times between '13:01 and 13:05'. BUT, when I choose '13:06' it gives me a score of '97'. I also get a score of '97' on '13:07 through 13:12' - which is the desired result. Why would I get a '97' right on '13:12' but not get a '99' right on '13:06'???? Could this be a memory leak or something???

    Read the article

  • IE8 and below <input type="image"> value work around

    - by kielie
    Hi guys, I have a slight problem, I am trying to capture the input of two buttons, one yes, one no, into a database but for some reason the database doesn't always show the value of the button clicked, it just shows up blank. <form action="refer.php" method="post" id="formID" > <div class="prompt_container" style="float: left;"> <span class="prompt_item"><input type="image" src="images/yes.jpg" alt="submit" value="yes" onclick="this.disabled=true,this.form.submit();" /></span> <input type="hidden" name="refer" value="yes"> </div> </form> <form action="thank_you.php" method="post" id="formID" > <div class="prompt_container" style="float: right;"> <span class="prompt_item"><input type="image" src="images/no.jpg" alt="submit" value="no" onclick="this.disabled=true,this.form.submit();" /></span> <input type="hidden" name="refer" value="no" > </div> </form> Apparently anything lower than IE8 will ignore the value attribute of all form inputs. How could I get this to work properly in all browsers? jQuery or Javascript maybe?

    Read the article

  • wget not completely processing the http call

    - by user578458
    Here is a wget command that executes a HTML / PHP stack report suite that is hosted by a third party - we don't have control over the PHP or HTML page wget --no-check-certificate --http-user=/myacc --http-password=mypass -O /tmp/myoutput.csv "https://myserver.mydomain.com/mymodule.php?myrepcode=9999&action=exportcsv&admin=myappuserid&password=myappuserpass&startdate=2011-01-16&enddate=2011-01-16&reportby=mypreferredview" All the elements are working perfectly: --http-user / --http-pass as offered by a browsers standard popup for username and password prompt -O /tmp/myoutput.csv - the output file of interest https://myserver.mydomain.com/mymodule.php?myrepcode=9999&action=exportcsv&admin=myappuserid&password=myappuserpass&startdate=2011-01-16&enddate=2011-01-16&reportby=mypreferredview" The file generated on the fly by the parameters myrepcode=9999 - a reference to the report in question action=exportcsv internally written in the function admin=myappuserid the third party operats SSL to access the site - then internal username and password stored in a database to access the functions of the site) password=myappuserpass startdate=2011-01-16 this and end data are parameters specific to the report 9999 enddate=2011-01-16 reportby=mypreferredview This is an option in the report that facilitates different levels of detail or aggregation The problem is that the reportby parameter is a radio button selection in a list of 5 selections (sure I enough the default is highest level of aggregation , I want the last one which is the most detailed) Here is a sample of the HTML page code for the options of reportby View by The Default My Least Preferred My Second Least Preferred My Third Least Preferred My Preferred No matter which of the reportby items I select in the wget statement - thedefault is always executed. Questions 1) Has anyone come across this notation in HTML (id=inputname[inputelement]) I spoke to a senior web developer and he has never seen this notation for inputs (id=inputname[inputelement]) - and w3schools do not appear familiar with this either based on an extensive search 2) Can a wget command select a none default radio item when executing the command ? This probably will be initially received with a "Use CURL" response- however the wget approach works very well in the limited environment I am operating in - particularly as I need to download 10000 of these such items. Thanks ahead of response

    Read the article

  • Rails dealing with blank params at controller level

    - by stephenmurdoch
    I have a User model: class User < ActiveRecord::Base has_secure_password # validation lets users update accounts without entering password validates :password, presence: { on: :create }, allow_blank: { on: :update } validates :password_confirmation, presence: { if: :password_digest_changed? } end I also have a password_reset_controller: def update # this is emailed to the user by the create action - not shown @user=User.find_by_password_reset_token!(params[:id]) if @user.update_attributes(params[:user]) # user is signed in if password and confirmation pass validations sign_in @user redirect_to root_url, :notice => "Password has been reset." else flash.now[:error] = "Something went wrong, please try again." render :edit end end Can you see the problem here? A user can submit a blank a password/confirmation and rails will sign them in, because the User model allows blank on update. It's not a security concern, since an attacker would still need access to a user's email account before they could get anywhere near this action, but my problem is that a user submitting 6 blank chars would be signed in, and their password would not be changed for them, which could lead to confusion later on. So, I've come up with the following solution, and I'd like to check if there's a better way of doing it, before I push to production: def update @user=User.find_by_password_reset_token!(params[:id]) # if user submits blank password, add an error, and render edit action if params[:user][:password].blank? @user.errors.add(:password_digest, "can't be blank.") render :edit elsif @user.update_attributes(params[:user]) sign_in @user redirect_to root_url, :notice => "Password has been reset." else flash.now[:error] = "Something went wrong, please try again." render :edit end end Should I be checking for nil as well as blank? Are there any rails patterns or idiomatic ruby techniques for solving this? [Fwiw, I've got required: true on the html inputs, but want this handled server side too.]

    Read the article

  • Dealing with Struts2 float conversion type

    - by Daniel Calderon Mori
    I have a question regarding float type conversion in Struts2. I have a form that contains a serie of normal input elements. A serie of textfields with an add button by the side of each one is included in the window. Clicking on one of this buttons has the effect of adding an input type "hidden" inside the form with the value of its correspondent textfield. That value will often be a float number that, this is very important, uses the point format (example: 1.34). The inputs created look like this: <input class="hidden_material" type="hidden" name="form[0].cantidad_formulacion" value='1.34'"> <input class="hidden_material" type="hidden" name="form[1].cantidad_formulacion" value='1.54'"> Anyway, the whole proccess is made correctly until the data is used by the server after the form submission. The numbers are present as if the point wouldn't have been placed in the number (using the example above, as 134). If a comma is used (as in 1,34), there wouldn't be a problem. But that will not be the case with the users of the system. How could I solve this problem?

    Read the article

  • How to map string keys to unique integer IDs?

    - by Marek
    I have some data that comes regularily as a dump from a data souce with a string natural key that is long (up to 60 characters) and not relevant to the end user. I am using this key in a url. This makes urls too long and user unfriendly. I would like to transform the string keys into integers with the following requirements: The source dataset will change over time. The ID should be: non negative integer unique and constant even if the set of input keys changes preferrably reversible back to key (not a strong requirement) The database is rebuilt from scratch every time so I can not remember the already assigned IDs and match the new data set to existing IDs and generate sequential IDs for the added keys. There are currently around 30000 distinct keys and the set is constantly growing. How to implement a function that will map string keys to integer IDs? What I have thought about: 1. Built-in string.GetHashCode: ID(key) = Math.Abs(key.GetHashCode()) is not guaranteed to be unique (not reversible) 1.1 "Re-hashing" the built-in GetHashCode until a unique ID is generated to prevent collisions. existing IDs may change if something colliding is added to the beginning of the input data set 2. a perfect hashing function I am not sure if this can generate constant IDs if the set of inputs changes (not reversible) 3. translate to base 36/64/?? does not shorten the long keys enough What are the other options?

    Read the article

  • Vim: How do I tell where a function is defined? (

    - by sixtyfootersdude
    I just installed macvim yesterday and I installed vim latex today. One of the menu items is calling a broken fuction (TeX-Suite -> view). When I click on the menu-time it makes this call: :silent! call Tex_ViewLatex() Question: Where can I find that function? Is there some way to figure out where it is defined? Just for curiosity sake I removed the silent part and ran this: :call Tex_ViewLatex() Which produces: Error detected while processing function Tex_ViewLaTeX: line 34: E121: Undefined variable: s:viewer E116: Invalid arguments for function strlen(s:viewer) E15: Invalid expression: strlen(s:viewer) line 39: E121: Undefined variable: appOpt E15: Invalid expression: 'open '.appOpt.s:viewer.' $*.'.s:target line 79: E121: Undefined variable: execString E116: Invalid arguments for function substitute(execString, '\V$*', mainfname, 'g' ) E15: Invalid expression: substitute(execString, '\V$*', mainfname, 'g') line 80: E121: Undefined variable: execString E116: Invalid arguments for function Tex_Debug line 82: E121: Undefined variable: execString E15: Invalid expression: 'silent! !'.execString Press ENTER or type command to continue I suspect that if I could see the source function I could figure out what inputs are bad or what it is looking for. Thanks.

    Read the article

  • Cant get JavaScipt to check for null objects

    - by CountMurphy
    I really don't know what the issue is here. Far as I can see, the code is simple and should work fine. var Prices=""; for (var PriceCount = 1; PriceCount <= 120; PriceCount++) { var CurrentPrice = "Price" + PriceCount; if (prevDoc.getElementById(CurrentPrice).value != null) { if (Prices == "") { Prices = prevDoc.getElementById(CurrentPrice).value; } else { Prices += "," + prevDoc.getElementById(CurrentPrice).value; } } else { break; } } There could be up to 120 hidden inputs on the form. The moment we check for an input that doesn't exist the loop should break. My test page has two input elements that get pulled. On the third (the null) I get this error in firebug: prevDoc.getElementById(CurrentPrice) is null if (prevDoc.getElementById(CurrentPrice).value != null) { Yes it is null...that's what the check is for ?_? Does any one know what I'm doing wrong? This seems like it should be really straight forward. EDIT: for clarity's sake, prevDoc=window.opener.document

    Read the article

  • I cant put a string in a switch nor an array in a class

    - by TimothyTech
    Okay, im making a pretty big file in my opinion, so i wanted to separate it into several files for cleaner code. so i have my main .cpp file and two header files holding my classes. well the header files dont hold strings, it aboslutely wont budge. i call the library in both my .cpp file and even tried it in my header file. another issue i ran into is using strings to make switches function, reason being if i use integers in a switch if the user inputs a alphabetical character the program goes into an endless loop. string choice; switch (choice) { case "1" : //... break; case "2" : //... break; } and my last issue is when i create an object in a case it gives an error. says cross initialization of object. string choice; switch (choice) { case "1" : Class object; break; case "2" : //... break; }

    Read the article

  • loop prematurely quitting

    - by Nick Gibson
    This loop works fine but prematurely quits at times. I set a piece of code in it so that I can view the random number. It only closes prematurely when the random number is equal to the highest numbered question the user inputs (Example...a user wants 10 questions, if the random number is 10 the program quits.) I have no idea why since i have it set to if(random number <= the number of questions) for ( int loop = 1; loop < loopCount; loop++ ) { aa = r.nextInt ( 10 + 1 ); abc = ( int ) aa; String[] userAnswer = new String[x]; JOptionPane.showMessageDialog ( null, abc ); if ( abc <= x ) { for ( overValue = 1; overValue < forLoop; overValue++ ); { userAnswer[j] = JOptionPane.showInputDialog ( null, "Question " + quesNum + "\n" + questions[abc] + "\n\nA: " + a[abc] + "\nB: " + b[abc] + "\nC: " + c[abc] + "\nD: " + d[abc] ); if ( userAnswer[j].equals ( answers[j] ) ) { JOptionPane.showMessageDialog ( null, "Correct. \nThe Correct Answer is " + answers[abc] ); } else { JOptionPane.showMessageDialog ( null, "Wrong. \n The Correct Answer is " + answers[abc] ); }//else }//for }//if }//for

    Read the article

  • How to create a String Array and link it to a Grade array

    - by user1861544
    I have a project that I need to create 2 Arrays, one to hold Student Names and one to hold Student Scores. The user inputs the size of the array, and the array needs to be sorted using BubbleSort (putting the high scores at the top). I have started the project, created the first array for scores, I have successfully done bubble sort and sorted the grades. Now I can't figure out how to make an array for Names, and once I do how do I make the names array correspond to the Grades array BubbleSort? Here is the code I have so far. import java.util.Scanner; public class Grades { public static void main(String[]args){ { Scanner UserIn = new Scanner(System.in); System.out.print( "How many students are there? " ); int[]GradeArray = new int[UserIn.nextInt()]; for( int i=0 ; i<GradeArray.length ; i++ ) { System.out.print( "Enter Grade for Student " + (i+1) + ": " ); GradeArray[i] = UserIn.nextInt(); } bubbleSort(GradeArray); for( int i : GradeArray ) System.out.println( i ); System.out.println(); } } private static void bubbleSort(int[]GradeArray){ int n = GradeArray.length; int temp = 0; String temp2; for(int i=0; i<n; i++){ for(int j=1; j<(n-i);j++){ if(GradeArray[j-1]<GradeArray[j]){ //swap temp=GradeArray[j-1]; GradeArray[j-1]=GradeArray[j]; GradeArray[j]=temp; } } } } } Also how do I change the grades to Double? I started with Int and when I try to change everything to double I get an error saying "Found Double, expected Int".

    Read the article

  • Query not being executed

    - by user2385241
    I'm trying to create a script that allows me to upload an image, grab the details sent through inputs (a description and chosen project number) and insert this information into a table. I currently have this function: public function NewEntry() { $connect = new dbconnect; $_SESSION['rnd'] = substr(number_format(time() * rand(),0,'',''),0,15); $allowedExts = array("gif", "jpeg", "jpg", "png"); $size = $_FILES["file"]["size"]; $path = $_FILES["file"]["name"]; $extension = pathinfo($path, PATHINFO_EXTENSION); $pr = $_POST['project']; $cl = $_POST['changelog']; $file = $_SESSION['rnd'] . "." . $extension; if (in_array($extension, $allowedExts) && $size < 200000000) { if ($_FILES["file"]["error"] == 0) { if (!file_exists("../uploads/" . $_SESSION['rnd'])) { move_uploaded_file($_FILES["file"]["tmp_name"], "../uploads/" . $_SESSION['rnd'] . "." . $extension); } } } else { echo "File validation failed."; } $row = $connect->queryExecute("INSERT INTO entries(project,file,changelog)VALUES($pr,$file,$cl)"); header('location:http://www.example.com/admin'); } When the form is posted the function runs, the image uploads but the query isn't executed. The dbconnect class isn't at fault as it's untampered and has been used in past projects. The error logs don't give any output and no MySQL errors show. Any ideas?

    Read the article

  • Handle edittexts onKeyListener ?

    - by hungson175
    Hi everyone, I am creating login screen with 2 editTexts: etUsername and etPassword. On the etUsername, user should input the username and press Enter to go to the edit text etPassword, then he inputs the password, press Enter to login. Here are my current codes: etUsername.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_ENTER)) { etPassword.requestFocus(); return true; } else return false; } }); etPassword.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_ENTER)) { loginToServer(); return true; } else return false; } }); But when I input the username, and then press Enter – the program tries to log in to the server. In the debug mode, I saw that when I pressed Enter once (on the etUsername) then first: etUsername.onKey() is called and then etPassword.onKey() is also called ! Can anyone please tell me, how to implement what I want ? Thank you very much, Son

    Read the article

  • How to reference input elements within a specific scope when there are multiple input elements of same kind?

    - by Will Merydith
    How do I select data for input elements within a specific scope? I have the same form multiple times (class "foo-form), and want to ensure I get the values for the hidden inputs within the scope of the form being submitted. Is the scope "this" implied? If not, what is the syntax for selecting input class "foo-text" within the scope of this? Feel free to point me to examples in the jquery docs - I could not find what I was looking for. $('.foo-form').submit(function() { // Store a reference to this form var $thisForm = $(this); }); <form class="foo-form"> <input type="hidden" class="foo-text"/> <input type="submit" class="button" /> </form> <form class="foo-form"> <input type="hidden" class="foo-text"/> <input type="submit" class="button" /> </form> <form class="foo-form"> <input type="hidden" class="foo-text"/> <input type="submit" class="button" /> // user clicks this submit button </form>

    Read the article

< Previous Page | 47 48 49 50 51 52 53 54 55 56 57 58  | Next Page >