Need some help regarding validation of input in a text field

Hello everyone,
i am new to all this website designing stuff and is working on my first website (treausre hunt types) and expecting some guidance over here.   :-)
I have successfully managed to validate the login page using server behaviour.
Let me explain what i need guidance with.
After login , the user is redirected to a page where a question is asked and he has to type the answer in the given text field and click on the submit button. Now i want to validate the given answer with the correct one and if it is answered correctly then the user is redirected to the next page.
the question is what and how am i supposed to do this?  i am using adobe dreamweaver cc and wampserver as localhost.

This becomes complicated to do it the way you want BUT YOU CAN do it - you just need to be a bit more efficient and get a template together.
Copy the 4 documents below and paste into seperate DW files to see how this works then look at the code and see if a pattern becomes noticeable to you. What we are doing is adding 1 to each level and checking the user has accumulated a score to that level - if not they are bumped down to the level which they have reached or in the case of not reaching any level to question 1.
question_1.php:
<?php
// Start the session
session_start();
?>
<?php
if (isset($_POST['submit'])) {
$answer = trim($_POST['answer']);
if(($answer == "Green" || $answer == "green")) {
$_SESSION['question'] = 2;
$correct = "<p>Correct Answer</p><p>You will automatically be taken to the next level</p>";
header( "refresh: 5; url=question_2.php" );
else {
$wrong = "<p>Wrong, please try again,</p>";
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Quiz</title>
<style>
p {
font-size: 20px;
color:#930;
margin: 0;
padding: 10px 0 8px 0;
</style>
</head>
<body>
<h3>Question 1.</h3>
<h2>What color is grass?</h2>
<form id="quiz" action="question_1.php" method="post">
<label for="answer">Answer<br>
<input type="text" name="answer" id="answer"></input>
<input type="submit" name="submit" value="Sumbit">
</label>
</form>
<?php
if(isset($wrong)) {
    echo $wrong;
elseif(isset($correct)) {
echo $correct;
?>
</body>
</html>
question_2.php
<?php
// Start the session
session_start();
?>
<?php
// This sends the user to question 1 if SESSION question has not been set
if(!isset($_SESSION['question'])) {
header('Location: question_1.php');
// This sends the user back if SESSION question is LESS than 2
if($_SESSION['question'] < 2) {
header('Location: question_1.php');
if (isset($_POST['submit'])) {
$answer = trim($_POST['answer']);
if(($answer == "Blue" || $answer == "blue")) {
    $_SESSION['question'] = $_SESSION['question']+1;
$correct = "<p>Correct Answer</p><p>You will automatically be taken to the next level</p>";
header( "refresh: 5; url=question_3.php" );
else {
$wrong = "<p>Wrong, please try again,</p>";
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Quiz</title>
<style>
p {
font-size: 20px;
color:#930;
margin: 0;
padding: 10px 0 8px 0;
</style>
</head>
<body>
<h3>Question 2.</h3>
<h2>What color is the sky?</h2>
<form id="quiz" action="question_2.php" method="post">
<label for="answer">Answer<br>
<input type="text" name="answer" id="answer"></input>
<input type="submit" name="submit" value="Sumbit">
</label>
</form>
<?php
if(isset($wrong)) {
    echo $wrong;
elseif(isset($correct)) {
echo $correct;
?>
</body>
</html>
question_3.php
<?php
// Start the session
session_start();
?>
<?php
// This sends the user to question 1 if SESSION question has not been set
if(!isset($_SESSION['question'])) {
header('Location: question_1.php');
// This sends the user back if SESSION question is LESS than 3
if($_SESSION['question'] < 3) {
header('Location: question_2.php');
if (isset($_POST['submit'])) {
$answer = trim($_POST['answer']);
if(($answer == "Yellow" || $answer == "yellow")) {
    $_SESSION['question'] = $_SESSION['question']+1;
$correct = "<p>Correct Answer</p><p>You will automatically be taken to the next level</p>";
header( "refresh: 5; url=question_4.php" );
else {
$wrong = "<p>Wrong, please try again,</p>";
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Quiz</title>
<style>
p {
font-size: 20px;
color:#930;
margin: 0;
padding: 10px 0 8px 0;
</style>
</head>
<body>
<h3>Question 3.</h3>
<h2>What color is the sun?</h2>
<form id="quiz" action="question_3.php" method="post">
<label for="answer">Answer<br>
<input type="text" name="answer" id="answer"></input>
<input type="submit" name="submit" value="Sumbit">
</label>
</form>
<?php
if(isset($wrong)) {
    echo $wrong;
elseif(isset($correct)) {
echo $correct;
?>
</body>
</html>
question_4.php
<?php
// Start the session
session_start();
?>
<?php
// This sends the user to question 1 if SESSION question has not been set
if(!isset($_SESSION['question'])) {
header('Location: question_1.php');
// This sends the user back if SESSION question is LESS than 4
if($_SESSION['question'] < 4) {
header('Location: question_3.php');
if (isset($_POST['submit'])) {
$answer = trim($_POST['answer']);
if(($answer == 4 || $answer == 4)) {
$_SESSION['question'] = $_SESSION['question']+1;
$correct = "<p>Correct Answer</p><p>You will automatically be taken to the next level</p>";
header( "refresh: 5; url=question_5.php" );
else {
$wrong = "<p>Wrong, please try again,</p>";
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Quiz</title>
<style>
p {
font-size: 20px;
color:#930;
margin: 0;
padding: 10px 0 8px 0;
</style>
</head>
<body>
<h3>Question 4.</h3>
<h2>What  is 2 + 2?</h2>
<form id="quiz" action="question_4.php" method="post">
<label for="answer">Answer<br>
<input type="text" name="answer" id="answer"></input>
<input type="submit" name="submit" value="Sumbit">
</label>
</form>
<?php
if(isset($wrong)) {
    echo $wrong;
elseif(isset($correct)) {
echo $correct;
?>
</body>
</html>

Similar Messages

  • Checking/Validating user input in a text field

    How can I validate a user's input in a text field and require them to input it in the following format:
    AAA 9999-999
    (where A can be letters and 9 can be numbers)
    Is there any documentation on how to validate user inputs in this manner?
    Thanks!
    BoilerUP

    Hi,
    Create a validation PL/SQL process, select Function returning Error and use something similar to the example below.
    I tested it but may be I missed something. I used field name P1_TEST.
    DECLARE
    v_number NUMBER;
    v_error VARCHAR2(1000);
    BEGIN
    --check if you have numbers in positions 5-8 and 10-12
    v_number:=SUBSTR(:P1_TEST,5,4);
    v_number:=SUBSTR(:P1_TEST,10);
    --check string length
    IF LENGTH(:P1_TEST)!=12 THEN
    RETURN 'String length must be 12 characters';
    END IF;
    --check if position 4 is empty
    IF INSTR(SUBSTR(:P1_TEST,4,1),' ')=0 THEN
    RETURN 'There should be a space between letters and numbers';
    END IF;
    --check if position 9 has "-"
    IF INSTR(SUBSTR(:P1_TEST,9,1),'-')=0 THEN
    RETURN 'There should be a dash between numbers';
    END IF;
    --check if positions 1-3 has letters
    FOR i IN 1 .. 3 LOOP
    SELECT ascii(substr(:P1_TEST, i, 1)) INTO v_number
    FROM Dual;
    IF v_number>=48 AND v_number<=59 THEN
    RETURN 'Only letters are allowed in positions 1,2,3';
    END IF;
    END LOOP;
    RETURN NULL;
    EXCEPTION
    WHEN OTHERS THEN
    v_error:=SQLERRM;
    IF INSTR(v_error, 'ORA-06502')>0 THEN
    RETURN '...must be integers only';
    ELSE
    RETURN v_error;
    END IF;
    END;
    I hope it will give you an idea on this type of validation.
    Val

  • I need some help Regarding Cumulative totals

    Hi ,
    i have a requirement
    1) we have columns calender Periods and actual to date. The requirement is we need cumulate the actual to date. i have applyed RSUM function in column formula.
    2) it is working fine. But again the requirement is this cumulative solution is changed based on selected calender periods. but this is not expected.
    3) ex:-
    calender period actual Units Cumulative Units
    oct - 2010 10 10
    Nov-2010 9 19
    Dec-2010 15 34
    Jan-2011 25 59
    Feb-2011 12 71
    March-2011 19 90
    April - 2011 13 103
    May - 2011 18 121
    June - 2011 24 145
    this is the reqiurement but i have a Prompt Like
    i hve selected resource categery some xyz and stert period is Jan -2011 and end period is May - 2011
    the values disply's like bellow
    Resource Category start Period End Period
    xyz Jan - 2011 May - 2011
    Jan-2011 25 25
    Feb-2011 12 37
    March-2011 19 58
    April - 2011 13 71
    May - 2011 18 89
    But this is not actual cumulative units the actual value for Jan 2011 cumulative value is 59 not 25
    can any one help me regarding this issue
    regards,
    ramesh

    Hi,
    Refer this link abt iview properties & set authorization ...
    http://help.sap.com/saphelp_nw04/helpdata/en/13/81a66d100011d7b84b00047582c9f7/frameset.htm
    Color- you have to change portal theme...
    Width- create a new Loyout..
    Regards,
    Senthil K.

  • Need some help regarding the backgrounds

    I am new to adobe dreamweaver & I would like to ask some sort of a stupid question
    When I save a website over the net, the folder always contains the background & the other images as small tiny images while when using Dreamweaver if I want to use a background image, I just load it.
    My question is do they actually load the background image as small parts or the browser devides the image to smaller parts when saving the page?
    Thanks for ur help & I hope some 1 gonna answer me soon enough.

    If you (or someone else) use a repeating background image (128X128 for instance) the browser, per instructions from the HTML or CSS, will "tile" the same image over and over to create the background. This doesn't display multiple copies of the image, but references it over and over alongside and below itself until the page reaches it's end.
    One exception to this is when there is a single large image (1024X768 for instance) used as a background, which usually doesn't repeat. In that case, if you were to download it, it would download as the one large image.
    Another exception is if the image is cut into pieces and put back together in divs inside the page. Often this is done to create the illusion of an image in a layer above the page, unrestricted by the square dimensions of HTML layout.

  • Need some help regarding Client Proxy generation and test via SOAMANAGER

    Hello,
    we are integrating a 3rd party Java client via webservices.
    For that matter I generated a client proxy (consumer proxy) in se80 using the existing WSDL.
    This worked fine.
    The I wanted to create a logical port.
    Since this is only possible in SOAMANAGER I tried it there.
    Trying to do this automatically by the given WSDL file didn't work. The system dumps.
    So, I tried the manual approach by entering the server name and path in the 'Transport settings' tab.
    Now I wanted to test this.
    Unfortunately the test function in se80 (Proxy->Test) doesn't show a positive result.
    I always get an error
    SOAP:1.023 SRT: Processing error in Internet Communication Framework: ("ICF Error when receiving the response:
    ICM_HTTP_CONNECTION_FAILED")
    So, I am kind of stuck here.
    Do you guys have any idea what's wrong (approach, settings, bugs)?.
    I tested the webservices with a test application (soapUI), and they work fine.
    So it seems to be a problem in the proxy framework or a network problem?
    I really appreciate any kind of help.
    Thanks,
    Michael

    i created the port in soamanager.Do i need to create in lpconfig also?
    yes i have loaded the certificate in strust.
    i am getting the response also from the web service. as Security requirements are not satisfied because the security header is not present in the incoming message.
    i need to pass the user name and password while using the method.wsse security.wld u have any clue?

  • Need some help regarding the component usage

    Dear ALL,
    I have one scenario something like this .
    I have a main component say ZComp1  and in it i have created one view in which we two drop downs and i have 28 view containers depending upon the drop down values these view containers will be visible here all the view container i am using for displaying by means of component usage (i.e 28 compoenents i am calling into my main ). So now when i run my main application it is taking minimu of 2 mins to display the screen .  To test whats the problem i have written some code in the handle default of main window and  set the break point what i observed is quite surprising that when i run the apllication it takes hardly 2 mins of time to reach my handledefault method (which is the first one to trigger when i run the apllicatin) . Please suggest me what can be doen to overcome this issue. or suggest some alternative to improve  performance.
    Note : When there is less amount of data in the screen then it takes less time to execute or else it takes hell lot of time plz suggest :(.
    Awaiting for your valuable suggestions.
    Regards,
    Sana.

    Hi Misbah,
    28 VCO are too much in  a view.
    So, try to revamp teh design and reduce the VCO's in a view.
    Another thing would be, Every WDDOINIT, and WDDOMODIFY view of the used components would be called when you try to load the component at first.
    In your case that is happening, and please check and confirm it.
    A proper modular design would be a better approach in handling the situation.
    Good day!
    Regards,
    Shashikanth. D

  • Need some help regarding PO numbering

    This is for a Real Estate Company. Here each Project is Inventory Org.
    Presently we are following automatic numbering for purchase orders.
    However here client is insisting for Purchase order numbering to be automatic- alpha numeric and again the crucial requirement is that it should be inventory organization(project) wise i.e. different alphanumeric numbering sequence for each inventory org.
    Eg: If we have two inventory orgs (say A, B) , then Purchase orders for A should follow numbering like A-001,A-002.......
    Similarly for inventory org B, it should be B-001,B-002....
    Can anyone suggest is there any way to achieve this..
    Ram

    So I have seen this done, but none of it was standard. You would leave your normal numbering system in place, but then have a SQL guy create a custom script to upload PO directly into your system. Typically with these loaders you can script in the use of any PO numbering scheme that you designate. If you migrated Oracle from a previous system you may have some of these tools especially if you had your historical data uploaded prior to going live. We used to call these PO Loaders, but the function operates in a similar fashion to a requisition loader which takes a flat file and uploads it directly into the system.

  • Need some help regarding value date

    hiii experts...i want little clarification about value date and its effects... i searched scn and google but my issue is like...when we receive cheque today i.e 11/06/2014... it will be come in bank a/cs nearly on 14/06/2014... so if we write the value date 14/06/2014... will that bank ledger show effect on 14/06/2014... moreoveer the user posted a entry development server for 1/3/2014 and gave value date of 1/4/2014.. now in faglb03... how it will reflect..i know its basic question but i didnt find any solution through searching soo posted... please guide me..
    Regards
    Abhay

    hey mani... thankss for the reply... its shows the meaning which i understood but the effect in ledger... when it will show... value date or posting date??
    e.g
    a customer gives cheque today 11/6/2014.. user deposits cheque today and it will come into bank account near on 14/6.2014..
    IN SAP
    user does entry today i.e 11/06/2014
    in bank g/l... he gives value date 14/06/2014... now when he posts the entry... the entry will shown in ledger on 11/06/2014... but the actual amount will come in 14/06/2014... soo my question is ... whts the user of value date then if he is posting the document on posting date

  • Need some help in creating Search Help for standard screen/field

    I need some help in adding a search-help to a standard screen-field.
    Transaction Code - PP01,
    Plan Version - Current Plan (PLVAR = '01'),
    Object Type - Position ( OTYPE = 'S'),
    Click on Infotype Name - Object ( Infotype 1000) and Create.
    I need to add search help to fields Object Abbr (P1000-SHORT) / Object Name (P1000-STEXT).
    I want to create one custom table with fields, Position Abb, Position Name, Job. Position Abb should be Primary Key. And when object type is Position (S), I should be able to press F4 for Object Abb/Object Name fields and should return Position Abbr and Position Name.
    I specify again, I have to add a new search help to standard screen/field and not to enhance it.
    This is HR specific transaction. If someone has done similar thing with some other transation, please let me know.
    There is no existing search help for these fields. If sm1 ever tried or has an idea how to add new search help to a standard screen/field.
    It's urgent.
    Thanks in advace. Suitable answers will be rewarded

    Hi Pradeep,
    Please have a look into the below site which might be useful
    Enhancing a Standard Search Help
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/daeda0d7-0701-0010-8caa-
    edc983384237
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ee93446011d189700000e8322d00/frameset.htm
    A search help exit is a function module for making the input help process described by the search help more flexible than possible with the standard version.
    This function module must have the same interface as function module F4IF_SHLP_EXIT_EXAMPLE. The search help exit may also have further optional parameters (in particular any EXPORTING parameters).
    A search help exit is called at certain timepoints in the input help process.
    Note: The source text and long documentation of the above-specified function module (including the long documentation about the parameters) contain information about using search help exits.
    Function modules are provided in the function library for operations that are frequently executed in search help exits. The names of these function modules begin with the prefix F4UT_. These function modules can either be used directly as search help exits or used within other search help exits. You can find precise instructions for use in the long documentation for the corresponding function module.
    During the input help process, a number of timepoints are defined that each define the beginning of an important operation of the input help process.
    If the input help process is defined with a search help having a search help exit, this search help exit is called at each of these timepoints. If required, the search help exit can also influence the process and even determine that the process should be continued at a different timepoint.
    timepoints
    The following timepoints are defined:
    1. SELONE
    Call before selecting an elementary search help. The possible elementary search helps are already in SHLP_TAB. This timepoint can be used in a search help exit of a collective search help to restrict the selection possibilities for the elementary search helps.
    Entries that are deleted from SHLP_TAB in this step are not offered in the elementary search help selection. If there is only one entry remaining in SHLP_TAB, the dialog box for selecting elementary search helps is skipped. You may not change the next timepoint.
    The timepoint is not accessed again if another elementary search help is to be selected during the dialog.
    2. PRESEL1
    After selecting an elementary search help. Table INTERFACE has not yet been copied to table SELOPT at this timepoint in the definition of the search help (type SHLP_DESCR_T). This means that you can still influence the attachment of the search help to the screen here. (Table INTERFACE contains the information about how the search help parameters are related to the screen fields).
    3. PRESEL
    Before sending the dialog box for restricting values. This timepoint is suitable for predefining the value restriction or for completely suppressing or copying the dialog.
    4. SELECT
    Before selecting the values. If you do not want the default selection, you should copy this timepoint with a search help exit. DISP should be set as the next timepoint.
    5. DISP
    Before displaying the hit list. This timepoint is suitable for restricting the values to be displayed, e.g. depending on authorizations.
    6. RETURN (usually as return value for the next timepoint)
    The RETURN timepoint should be returned as the next step if a single hit was selected in a search help exit.
    It can make sense to change the F4 flow at this timepoint if control of the process sequence of the Transaction should depend on the selected value (typical example: setting SET/GET parameters). However, you should note that the process will then depend on whether a value was entered manually or with an input help.
    7. RETTOP
    You only go to this timepoint if the input help is controlled by a collective search help. It directly follows the timepoint RETURN. The search help exit of the collective search help, however, is called at timepoint RETTOP.
    8. EXIT (only for return as next timepoint)
    The EXIT timepoint should be returned as the next step if the user had the opportunity to terminate the dialog within the search help exit.
    9. CREATE
    The CREATE timepoint is only accessed if the user selects the function "Create new values". This function is only available if field CUSTTAB of the control string CALLCONTROL was given a value not equal to SPACE earlier on.
    The name of the (customizing) table to be maintained is normally entered there. The next step returned after CREATE should be SELECT so that the newly entered value can be selected and then displayed.
    10. APP1, APP2, APP3
    If further pushbuttons are introduced in the hit list with function module F4UT_LIST_EXIT, these timepoints are introduced. They are accessed when the user presses the corresponding pushbutton.
    Note: If the F4 help is controlled by a collective search help, the search help exit of the collective search help is called at timepoints SELONE and RETTOP. (RETTOP only if the user selects a value.) At all other timepoints the search help exit of the selected elementary search help is called.
    If the F4 help is controlled by an elementary search help, timepoint RETTOP is not executed. The search help exit of the elementary search help is called at timepoint SELONE (at the
    F4IF_SHLP_EXIT_EXAMPLE
    This module has been created as an example for the interface and design of Search help exits in Search help.
    All the interface parameters defined here are mandatory for a function module to be used as a search help exit, because the calling program does not know which parameters are actually used internally.
    A search help exit is called repeatedly in connection with several
    events during the F4 process. The relevant step of the process is passed on in the CALLCONTROL step. If the module is intended to perform only a few modifications before the step, CALLCONTROL-STEP should remain unchanged.
    However, if the step is performed completely by the module, the following step must be returned in CALLCONTROL-STEP.
    The module must react with an immediate EXIT to all steps that it does not know or does not want to handle.
    Hope this info will help you.
    ***Reward points if found useful
    Regards,
    Naresh

  • Need some help in LiveCycle Designer ES 8.2

    Hi i need help with tables in livecyckle.
    Example. I create one table with 32 rows and 8 numretic cells, and another table below with 1 row and 8 numretic cells.
    In the big table i can input numbers and working fine.
    now to my problem. Ex, i want to input number 12 in row 1 cell 3.and then again same number 12 in row 2 cell 3 and i want the result (24) in table 2 row 1 cell 3. is there anyboby who can help me with that See below
    Header 1
    Header 2
    Header 3
    Header 4
    Header 5
    Header 6
    Header 7
    Header 8
    12
    3
    5
    12
    7
    9
    4
    Header 1
    Header 2
    Header 3
    Header 4
    Header 5
    Header 6
    Header 7
    Header 8
    4
    24
    10
    14
    Best regards    Stig

    Hi again Steve and thanx for the reply..send you a coupie of my file.
    All text on it is in swedish so i can explain a little for you.
    Text Veckodag is Weekday,Tim is hours. Frånv. is a shortname for sickness,
    Dagtid is daytime Kväll is evening, Helg is weekends, Afton is Big weekend
    like christmas day, s-helg is a shortname for big weekendsdays like day
    after christmas day, Jour is jour. The field to the left with numbers is
    date. Totalt is total
    The only fields i need some help with is the field from Tim to Jour. And the
    result should apear in the last fielt Totalt
    Can also tell that im not so good in english but im learning. And the last
    thing of all :Happy easter to you and thanxs again.
    Stig in sweden My E-mail adress is [email protected]

  • Need Some help in Developing an ALV report ..Plz help me

    Hi Experts I am basic learner to ABAP Here I need some help in developing a Delivery *** Invoice Report....Please help me by spending a little time..
    Tables are VBAK VBAP LIPS LIKP   and Document floe table is VBFA
      SELECT VBELN VKORG VTWEG SPART
        FROM VBAK
        INTO TABLE I_VBAK
        WHERE VBELN IN S_VBELN.
      IF I_VBAK IS NOT INITIAL .
        SELECT VBELN POSNR MATKL POSAR WERKS
          FROM VBAP
          INTO TABLE I_VBAP
          FOR ALL ENTRIES IN I_VBAK
          WHERE VBELN = I_VBAK-VBELN.
      ENDIF.
      IF I_VBAP IS NOT INITIAL.
        SELECT * FROM LIPS
          INTO CORRESPONDING FIELDS OF TABLE I_LIPS
          WHERE VGBEL = VBAP-VBELN
          AND VGPOS = VBAP-POSNR.
      ENDIF.
      IF I_LIPS IS NOT INITIAL.
        SELECT VBELN VSTEL VKORG KUNNR
        FROM LIKP
        INTO TABLE I_LIKP.
      ENDIF.
    Moderator message : Outsourcing is not allowed, don't expect others to correct your source code. Thread locked.
    Edited by: Vinod Kumar on Aug 1, 2011 5:43 PM

    hi ,
      Look in this link
      <a href="http://help.sap.com/saphelp_nw04/helpdata/en/b3/0ef3e8396111d5b2e80050da4c74dc/frameset.htm">http://help.sap.com/saphelp_nw04/helpdata/en/b3/0ef3e8396111d5b2e80050da4c74dc/frameset.htm</a>
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/21/894eeee0b911d4b2d90050da4c74dc/content.htm">http://help.sap.com/saphelp_nw04/helpdata/en/21/894eeee0b911d4b2d90050da4c74dc/content.htm</a>
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/80/1a62bfe07211d2acb80000e829fbfe/content.htm">http://help.sap.com/saphelp_nw04/helpdata/en/80/1a62bfe07211d2acb80000e829fbfe/content.htm</a>
    Regards
    Renjith Kumar

  • Need some help in Rounding a double value to a whole number

    Hey Peeps,
    Need some help here, I got a method that returns a value in double after a series of calculation.
    I need to know how can I round the double value, so for example,
    1. if the value is 62222.22222222, it rounds to 62222 and
    2. if the value is 15555.555555, it rounds to 15556
    How can i do this
    Zub

    Hi Keerthi- Try this...
    1. if the value is 62222.22222222, it rounds to 62222 and
    double d = 62222.22222222;long l = (int)Math.round(d * 100); // truncatesd = l / 100.0;
    double d = 62222.22222222;
    System.out.println(d);
    long l = (int)Math.round(d * 100);
    // truncatesSystem.out.println(l);
    d = l / 100.0;System.out.println(d);
    for (int i = 0; i < 1000; i++)
    {    d -= 0.1;}
    for (int i = 0; i < 1000; i++)
    {    d += 0.1;}System.out.println(d);
    regards- Julie Bunavicz
    Output:
    62222.22222222
    62222
    62222.22
    62222.22000000000001

  • Need some help...in need of a different way.

    Hi, I'm new to Java and need some help. I have 2 questions that are similar in nature.
    1st Question:
    In a program that I'm writting I have a do-while loop which at the end brings up a dialog box that asks the user to enter '1' for 'Yes' or '2' for 'No' to continue.
    I would rather have the option of having the user enter 'y' or 'Y' for Yes and 'n' or 'N' for No.
    Here is what I have currently:
    int x;
    String data;
    do{
    //Blah blah code
    data = JOptionPane.showInputDialog(null, "Enter 1 for Yes or 2 for No");
    x = Integer.parseInt(data);
    }while(x == 1);
    x++;
    2nd Question:
    In another part of my program I have a Case statement that asks the user to enter a number or a letter from a list of choices. They can enter '2' , 't', or 'T'.
    I would rather have all of this in an if-else chain. Is this possibe? if so, how would I do it.
    Thanks.

    I would rather have the option of having the user enter 'y' or 'Y' for Yes and 'n' or
    'N' for No. You can test the first letter of whatever the user inputs like this:String response = JOptionPane.showInputDialog(null, "Enter (Y)es or (N)o");
    response = response.toLowerCase();
    if(response.startsWith("y")) {
        // the user entered something starting with y
    } else if(response.startsWith("n")) {
        // the user entered something starting with n
    } else {
        // what are you going to do?
    }JOptionPane also has versions that would allow yes/no buttons. Eg, see:
    http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html

  • Hi, can anyone help me out with this, I need some help on designing GUI for e-learning coursewares. Some tutorials or some helpful sites will do.

    I need some help with the GUI design.

    Have you tried the line inputs on the back of your FirePod? If you update its firmware (not sure if you will need to or not), I seem to remember hearing that the FirePod can run without FW connection, i.e. stand alone. In this mode with the outs from your mixer into line ins 1-2 (2nd from left on the back) it should work fine. I say should because I have never tried. However, these are used for returns from an external effects unit. I assume here, and the important word is assume, that there are two so that they can be used as a stereo send or as a mono send. Worth a try! Let us know how it goes.
    Best, Fred

  • Need some help with a remove function

    Design and code a program that will maintain a list of product names. Use a String type to represent the product name and an array of strings to implement the list. Your program must implement the following methods:
    Add a product to the list
    Remove a product from the list
    Display then entire list
    Find out if a particular product is on the list.
    You need to create a command command loop with a menu() function. The program must continue asking for input until the user stops.
    This is the assignment and this is what I have so far. I need some help writing the remove function.
    Thanks
    * Title: SimpleSearchableList.java
    * Description: this example will show a reasonably efficient and
    * simple algorithm for rearranging the value in an array
    * in ascending order.
    public class SimpleSearchableList {
         private static String[] List = new String[25]; //These variables (field variables)
         private static int Size; //are common to the entire class, but unavailable
         //except to the methods of the class...
         public static void main(String[] args)
              String Cmd;
              for(;;) {
                   Menu();
                   System.out.print("Command: ");
                   Cmd = SimpleIO.inputString();
                   if(Cmd.equals("Quit"))
                        break;
                   else if(Cmd.equals("Fill"))
                        FillList();
                   else if(Cmd.equals("Search"))
                        SearchList();
                   else if(Cmd.equals("Show"))
                        ShowList();
                   else if(Cmd.equals("Remove"))
                        Remove();
         //Tells you what you can do...
         public static void Menu()
              System.out.println("Choices..................................");
              System.out.println("\tFill to Enter Product");
              System.out.println("\tShow to Show Products");
              System.out.println("\tSearch to Search for Product");
              System.out.println("\tRemove a Product");
              System.out.println("\tQuit");
              System.out.println(".........................................");
         //This method will allow the user to fill an array with values...
         public static void FillList()
              int Count;
              System.out.println("Type Stop to Stop");
              for(Count = 0 ; Count < List.length ; Count++)
                   System.out.print("Enter Product: ");
                   List[Count] = SimpleIO.inputString();
                   if(List[Count].equals("Stop"))
                        break;
              Size = Count;
         //This method will rearrange the values in the array so that
         // go from smallest to largest (ascending) order...
         public static void SearchList()
              String KeyValue;
              boolean NotFoundFlag;
              int Z;
              System.out.println("Enter Product Names Below, Stop To Quit");
              while(true)
                   System.out.print("Enter: ");
                   KeyValue = SimpleIO.inputString();
                   if(KeyValue.equals("Stop")) //Note the use of a method for testing
                        break; // for equality...
                   NotFoundFlag = true; //We'll assume the negative
                   for(Z = 0 ; Z < Size ; Z++)
                        if(List[Z].equals(KeyValue)) {
                             NotFoundFlag = false; //If we fine the name, we'll reset the flag
              System.out.println(List[Z] + " was found");
                   if(NotFoundFlag)
                        System.out.println(KeyValue + " was not found");     
         //This method will display the contents of the array...
         public static void ShowList()
              int Z;
              for(Z = 0 ; Z < Size ; Z++)
                   System.out.println("Product " + (Z+1) + " = " + List[Z]);
         public static void Remove()
    }

    I need help removing a product from the arrayYes. So what's your problem?
    "Doctor, I need help."
    "What's wrong?"
    "I need help!"
    Great.
    By the way, you can't remove anything from an array. You'll have to copy the remaining stuff into a new one, or maybe maintain a list of "empty" slots. Or null the slots and handle that. The first way will be the easiest though.

Maybe you are looking for

  • Site to Site VPN with Overlapping network and other network Access..

    Hi all, i need to setup a site to site Tunnel to a remote site. My remote site got the network which has overlapped with one of our network(192.168.10.0/24) in my site. remote site dont need to access this network(192.168.10.0/24) in my site ,but the

  • How can I export table and cell styles to use in another InDesign document?

    I've been looking-and looking but can't find out how to export table styles within InDesign CC. If there is a load table styles option within the panel, it stands to reason there should be an export. Any help would be appreciated, thanks.

  • Video and audio not in sync (ALSA underrun occurred)

    Hi, after a recent system upgrade (upgrade log here http://pastebin.com/1gRwexFr), video and sound are not in sync anymore. The problem occurs in mplayer instantly, and in XBMC after a while (the audio is slowly getting out of sync). The error messag

  • Doubt with Iview Team Calendar

    Dear I have the following issue. The system in the iview Team Calendar is showing an employee that are not to the Organizational Unit of the Boss. The employee "Jorge" had a organizational change from 23.08.2011. In the iview Team General Information

  • Purchase requisition must be create with material codes only

    Hi gays, Can u solve my problem. We are having  "3 " document types to create purchase requisition. 3 types are using different depts. I need to restrict the 1 document type with material code only they should raise the purchase requisition. other 2