Click here to Skip to main content
15,888,314 members
Home / Discussions / JavaScript
   

JavaScript

 
GeneralRe: What do you think of this? Pin
Super Lloyd27-Jun-13 15:20
Super Lloyd27-Jun-13 15:20 
QuestionOnpage pagination is not working Pin
Md Shariful Islam Saful26-Jun-13 8:01
Md Shariful Islam Saful26-Jun-13 8:01 
AnswerRe: Onpage pagination is not working Pin
Dennis E White26-Jun-13 15:14
professionalDennis E White26-Jun-13 15:14 
QuestionUsing a switch statement to count variables in an array Pin
tristarterror24-Jun-13 11:09
tristarterror24-Jun-13 11:09 
AnswerRe: Using a switch statement to count variables in an array Pin
fixthebugg24-Jun-13 11:35
fixthebugg24-Jun-13 11:35 
AnswerRe: Using a switch statement to count variables in an array Pin
lmf232s24-Jun-13 12:07
lmf232s24-Jun-13 12:07 
AnswerRe: Using a switch statement to count variables in an array Pin
Manfred Rudolf Bihy24-Jun-13 20:06
professionalManfred Rudolf Bihy24-Jun-13 20:06 
QuestionVariables not showing correctly in HTML Pin
tristarterror24-Jun-13 9:17
tristarterror24-Jun-13 9:17 
I am currently a college student so please be kind to me being a novice! I am working on an assignment and I just can't figure out where I am going wrong.

Assignment Details:
Function: tst_name
Parameter: A string.
Returns: true if the given string has the form
String1, String2 letter
where both strings must be all lowercase letter except for the first letter and letter must be uppercase; false otherwise

My JavaScript file:
C#
function tst_name(name) {
    // simple pattenr to check the format of the name
    var ok = name.search(/^[A-Z][a-z]+, [A-Z][a-z]+, [A-Z]\.?$/);

    if (ok == 0) {
        return true;
    } else {
        return false;
    }
} // end of function tst_name

// Test function with two sets of data
var tst = tst_name(Woods, Trista, M);
if (tst) {
    document.write("Program error <br />");
} else {
    document.write("Valid name. <br />");
}

var tst = tst_name(woods, trista, m);
if (tst) {
    document.write("Invalid name <br />");
} else {
    document.write("Program error <br />")
}


My HTML file:
XML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd"
    >
<html lang="en">
<head>
    <title>Woods | Test Name | Exercise 4.12</title>
    <script type="text/javascript" src="exercise4-12.js">
    </script>
</head>
<body>
  <script>
    document.write("Woods, Trista, M: " + tst + "<br />");
    document.write("woods, trista, m: " + tst + "<br />");
  </script>
</body>
</html>


When I view this in a browser it just shows:
Woods, Trista, M: undefined
woods, trista, m: undefined

So I'm just confused. I followed an example in our book and I just don't know what I need to do in order to get the variables to write the correct statements in my HTML document.
AnswerRe: Variables not showing correctly in HTML Pin
dusty_dex24-Jun-13 9:45
dusty_dex24-Jun-13 9:45 
GeneralRe: Variables not showing correctly in HTML Pin
tristarterror24-Jun-13 10:16
tristarterror24-Jun-13 10:16 
GeneralRe: Variables not showing correctly in HTML Pin
dusty_dex24-Jun-13 10:55
dusty_dex24-Jun-13 10:55 
Questionhow make a skype call by getting a phone number from textbox Pin
Pasqualissimo23-Jun-13 12:20
Pasqualissimo23-Jun-13 12:20 
QuestionMSN style links Pin
Bart23-Jun-13 10:20
Bart23-Jun-13 10:20 
AnswerRe: MSN style links Pin
thanh_bkhn23-Jun-13 16:09
professionalthanh_bkhn23-Jun-13 16:09 
GeneralRe: MSN style links Pin
Bart25-Jun-13 10:22
Bart25-Jun-13 10:22 
QuestionHow to show info marker google maps when clicked in outside map? Pin
Akbarblack22-Jun-13 4:12
Akbarblack22-Jun-13 4:12 
AnswerRe: How to show info marker google maps when clicked in outside map? Pin
Dan Randolph23-Jun-13 8:55
Dan Randolph23-Jun-13 8:55 
GeneralRe: How to show info marker google maps when clicked in outside map? Pin
Akbarblack10-Dec-13 20:32
Akbarblack10-Dec-13 20:32 
QuestionShopping Cart Qty Button - I need to make it faster Pin
jkirkerx21-Jun-13 11:16
professionaljkirkerx21-Jun-13 11:16 
AnswerRe: Shopping Cart Qty Button - I need to make it faster Pin
enhzflep24-Jun-13 11:19
enhzflep24-Jun-13 11:19 
GeneralRe: Shopping Cart Qty Button - I need to make it faster Pin
jkirkerx24-Jun-13 11:38
professionaljkirkerx24-Jun-13 11:38 
GeneralRe: Shopping Cart Qty Button - I need to make it faster Pin
enhzflep24-Jun-13 12:15
enhzflep24-Jun-13 12:15 
GeneralRe: Shopping Cart Qty Button - I need to make it faster Pin
jkirkerx24-Jun-13 12:33
professionaljkirkerx24-Jun-13 12:33 
GeneralRe: Shopping Cart Qty Button - I need to make it faster Pin
enhzflep24-Jun-13 12:53
enhzflep24-Jun-13 12:53 
QuestionJavascript, KnockoutJS (and possibly TypeScript) Pin
_Maxxx_19-Jun-13 18:32
professional_Maxxx_19-Jun-13 18:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.