Jump to content

davej

Moderator
  • Posts

    3,988
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by davej

  1. Since the file contains a series of rather complex word definitions such as...

    <p><b><h1>shrugs
    </h1></b></p><div class="source-data">
            <div class="def-list">
                                            <section class="def-pbk ce-spot" data-collapse-expand='{"target": ".def-set", "type": "def"}'>
                        <header class="luna-data-header">
                            <span class="dbox-pg">verb (used with object)</span>, <span class="dbox-bold">shrugged, </span><span class="dbox-bold" data-syllable="shrug·ging.">shrugging.</span>                    </header>
    
                                                
    <div class="def-set">
        <span class="def-number">1.</span>
        <div class="def-content">
            to raise and contract (the shoulders), expressing indifference, disdain, etc.    </div>
    </div>
                                        </section>
                                <section class="def-pbk ce-spot" data-collapse-expand='{"target": ".def-set", "type": "def"}'>
                        <header class="luna-data-header">
                            <span class="dbox-pg">verb (used without object)</span>, <span class="dbox-bold">shrugged, </span><span class="dbox-bold" data-syllable="shrug·ging.">shrugging.</span>                    </header>
    
                                                
    <div class="def-set">
        <span class="def-number">2.</span>
        <div class="def-content">
            to raise and contract the shoulders.    </div>
    </div>
                                        </section>
                                <section class="def-pbk ce-spot" data-collapse-expand='{"target": ".def-set", "type": "def"}'>
                        <header class="luna-data-header">
                            <span class="dbox-pg">noun</span>                    </header>
    
                                                
    <div class="def-set">
        <span class="def-number">3.</span>
        <div class="def-content">
            the movement of raising and contracting the shoulders.    </div>
    </div>
                                                
    <div class="def-set">
        <span class="def-number">4.</span>
        <div class="def-content">
            a short sweater or jacket that ends above or at the waistline.    </div>
    </div>
                                        </section>
                                <section class="def-pbk ce-spot" data-collapse-expand='{"target": ".def-set", "type": "def"}'>
                        <header class="luna-data-header">
                            <span class="dbox-pg">Verb phrases</span>                    </header>
    
                                                
    <div class="def-set">
        <span class="def-number">5.</span>
        <div class="def-content">
            <span class="dbox-bold">shrug off, </span>            <ol class="def-sub-list">
                                        <li>
                            to disregard; minimize:                             <div class="def-block def-inline-example"><span class="dbox-example">to shrug off an insult.</span></div>
                                                </li>
                                        <li>
                            to rid oneself of:                             <div class="def-block def-inline-example"><span class="dbox-example">to shrug off the effects of a drug.</span></div>
                                                </li>
                                </ol>
                            </div>
    </div>
                                        </section>
                        </div>
    
            <div class="tail-wrapper">
    
        

    ...are you saying you would like the above to be converted into...

    shrugs,verb (used with object),shrugged,shrugging.,1.,to raise and contract (the shoulders),expressing indifference, disdain, etc.,verb (used without object),shrugged,shrugging.,2.,to raise and contract the shoulders.,3.,the movement of raising and contracting the shoulders.,4.,a short sweater or jacket that ends above or at the waistline.,,Verb phrases,5.,shrug off, to disregard; minimize:,to shrug off an insult.,to rid oneself of:,to shrug off the effects of a drug.
    

    ...this introduces several problems. For one thing there are embedded commas in the text. Also each element is variable in length.

  2. The idea of a foreign key is that the database would not allow you to enter a non-existent order_number in your cust_time table. It would only accept order_numbers that already exist in the customer table.

    • Like 1
  3.  

    This code demonstrates the use of methods, similar to what you seemed to be attempting to do. Obviously sendKeys() requires a string rather than an integer.

     

    public class Newcoder0001 {
        
        public static void main(String[] args) {
            // Create a new instance of the Firefox driver
            // Notice that the remainder of the code relies on the interface, 
            // not the implementation.
            WebDriver driver = new FirefoxDriver();
    
            // And now use this to visit myPage
            driver.get("http://www.myPage.com");
            // Alternatively the same thing can be done like this
            // driver.navigate().to("http://www.myPage.com");
    
          
            enterPhoneExt(driver, 999);
         
    /*
            // Now submit the form. WebDriver will find the form for us from the element
            element.submit();
    
            // Check the title of the page
            System.out.println("Page title is: " + driver.getTitle());
            
            // Google's search is rendered dynamically with JavaScript.
            // Wait for the page to load, timeout after 10 seconds
            (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
                public Boolean apply(WebDriver d) {
                    return d.getTitle().toLowerCase().startsWith("cheese!");
                }
            });
    
            // Should see: "cheese! - Google Search"
            System.out.println("Page title is: " + driver.getTitle());
            
            //Close the browser
            driver.quit();
    */
        }// end of main
        
        static void enterPhoneExt(WebDriver driver, int max){
        
            WebElement element = driver.findElement(By.name("PhoneExtField")); // select element
            element.clear();
            int n = generateRandomNumber(max);
            element.sendKeys( String.valueOf(n) ); // insert int as a string
            
        }// end of method
        
        static int generateRandomNumber(int max){
        
            Random rand = new Random();
            int  n = rand.nextInt(max-1) + 1;
            return n;
            
        }// end of method
        
    }// end of class

     

  4. Let's start with example code and then modify it. The following is from the seleniumhq.org example

    public class Selenium2Example  {
        public static void main(String[] args) {
            // Create a new instance of the Firefox driver
            // Notice that the remainder of the code relies on the interface, 
            // not the implementation.
            WebDriver driver = new FirefoxDriver();
    
            // And now use this to visit Google
            driver.get("http://www.google.com");
            // Alternatively the same thing can be done like this
            // driver.navigate().to("http://www.google.com");
    
            // Find the text input element by its name
            WebElement element = driver.findElement(By.name("q"));
    
            // Enter something to search for
            element.sendKeys("Cheese!");
    
            // Now submit the form. WebDriver will find the form for us from the element
            element.submit();
    
            // Check the title of the page
            System.out.println("Page title is: " + driver.getTitle());
            
            // Google's search is rendered dynamically with JavaScript.
            // Wait for the page to load, timeout after 10 seconds
            (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
                public Boolean apply(WebDriver d) {
                    return d.getTitle().toLowerCase().startsWith("cheese!");
                }
            });
    
            // Should see: "cheese! - Google Search"
            System.out.println("Page title is: " + driver.getTitle());
            
            //Close the browser
            driver.quit();
        }
    }

     

  5. 9 hours ago, armandesigner said:

    It is web actually every language on web is acceptable.

    Yes, if you are only communicating via the internet, and not using a browser, but each language is different. You would not use the same code or probably even the same language in Windows as you would in Linux.

    • Like 1
  6. On 8/2/2017 at 0:18 PM, armandesigner said:

    Hello guys I have a program actually I made it and it works online actually we can use it in host or servers but I want to know can we do something that we can use it offline but in offline web we can do whatever it has for example using all the feature.

    You have a program written in what? It seems to me that this is either an Android Java question or an iOS Swift question. Or is it Javascript that was loaded from a website which it has now lost connectivity to? Which is it?

    • Like 1
  7. On 4/13/2017 at 6:22 PM, TheShadowGamer said:

    He wants JavaScript, HTML, CSS and he recommended using JSON [...]

    • Take in and store user input from at least 5 different questions answered by the user via HTML form elements (2 points)
    • Use an array of options to correlate user data to a matrix of potential results you've designed (2 points)
    • Dynamically display appropriate result images and text to the user after completing the questions (2 points)
    • Format appropriately for use on a mobile, tablet, or desktop screen using media queries (2 points)
    • Include original content that communicates an idea to the user through an engaging interaction (2 points)

     

    Yeah, it seems odd that the multi-page requirement isn't listed above, but the OP made it clear that it was also one of the requirements. Several of the bullet items seem rather vague to me. What sort of array of options? What is an "engaging interaction?"

  8. On 4/13/2017 at 5:13 PM, TheShadowGamer said:

    I wish it were that simple but our teacher wants it one question per page and we have to transfer the data page by page and then give the user a personality, or in my case spirit animal based on the answers they provided.

    Another issue is he recommended using JSON, but we've never even used it before.

     

  9. He told us this was a school assignment, so I don't want to simply post a solution. He also told us it must consist of multiple pages with one question per page. His instructor told him to use only HTML, CSS and Javascript. His Javascript code is filled with errors and does not display an understanding of what needs to be done. We told him to look at Local Storage several times.

  10. Okay, if there is only one question per page then why do you need a submit button? The way you had it before you edited it was fine. If you only have one question per page then why does your code need a loop? Your else-if's are wrong and you are confusing = and ==.

    If indeed you have only one question per page then you simply have the buttons store the answer and then jump to the next page. Only the final page will do any calculations.

    I guess you can have a submit button if you want it, but that adds complexity because then you would probably want to change the style of the selected button. If you immediately jump to the next page then you don't need to consider styling that button.

  11. 1 hour ago, TheShadowGamer said:

    [...]...our teacher wants it one question per page and we have to transfer the data page by page and then give the user a personality, or in my case spirit animal based on the answers they provided.

     

    What are the prerequisites for this class? What languages does s/he expect you to use?

  12. Try...

    <script>
    'use strict';
    
    function init() {
    var buttons = document.getElementsByClassName('btn');
    for(var i=0 ; i<buttons.length ; i++){
       buttons[i].onclick = clkhandler;
    }
    }
    
    function clkhandler(evt){
       var ans = evt.target.innerHTML;
       var ques = evt.target.parentNode.getElementsByClassName('text')[0].innerHTML;
       alert(ques + " = " + ans);
    }
    
    window.onload = init;
    </script>

     

  13. It sounds like you are talking about two different things. You could use a JSON string to dynamically create the form or you could read the submitted form and create a JSON string for AJAX, or you could do both. I don't think it would be efficient to use the same JSON structure to do both.

     

×
×
  • Create New...