passing values from onClick

Hamruniz

Given the following code, how do I pass the values of day, month and year from the onCLick form to generate the variable $date in the script?

<head>

<!--

/* Generate day name script */

$date = "day. .month. .year";

function inDate() {
    s = $date;
    if (s != "" && s != null) determineDay(s);
    alert ("Name date is "+$wDay+);
}

//-->

</head>

<body>

<input type="text" value="day" id="day" />
<input type="text" value="month" id="month" />
<input type="text" value="year" id="year" />

<form name='f1'><input value='Generate Day name' onclick='inDate()' type='button'></form>

</body>
GitaarLAB

This appears to be what you are doing and should help you get started:

var date, wDay; //global vars

function determineDay(date){
  // set global var wDay
  wDay = [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday'
         , 'Thursday', 'Friday', 'Saturday' 
         ][ date.getUTCDay() ];
}

function inDate(){
  // Set global var date
  date = new Date( Date.UTC( +document.getElementById('year').value
                           ,  document.getElementById('month').value -1 //month is zero-based
                           , +document.getElementById('day').value
                           )        
                 );
  if( !isNaN(date) ){       // test for invalid date
    determineDay(date);
    alert(  'Name date is ' + wDay  );
  }
}
<input type="text" value="day" id="day" />
<input type="text" value="month" id="month" />
<input type="text" value="year" id="year" />

<form name="f1"><input value="Generate Day name" onclick="inDate()" type="button"></form>

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Passing values from HTML to SCSS

分類Dev

Passing values from an Activity into a ListView in another activity and saving these values

分類Dev

Passing values from controller into javascript in mvc5

分類Dev

AngularJS Passing changing values from Controller to a Directive Controller

分類Dev

Passing argument by value to onClick function

分類Dev

Passing values to a variable

分類Dev

JavaFX bindings not passing on values

分類Dev

pytest fixture passing values

分類Dev

Passing in constructor values into a method?

分類Dev

Encoding and Passing JSON Object from multiple input values on Create method in Laravel 5.1 Controller

分類Dev

passing correlated values to a function in Oracle

分類Dev

Passing form values by id in modal

分類Dev

Scope of variables and Passing values in java

分類Dev

Passing multiple values as method parameter

分類Dev

Passing data from IntentService

分類Dev

Passing multiple onClick parameters using div.innerHTML

分類Dev

Passing list of enum values as HTTP query parameters

分類Dev

Passing list of enum values as HTTP query parameters

分類Dev

Passing chosen multi select values to controller action

分類Dev

Passing values directly to setter method using for loop

分類Dev

Passing Values while handling/calling jQuery event

分類Dev

Python : passing values between different processes

分類Dev

Passing Values Between Windows Forms c#

分類Dev

Passing <p:inputText> values to Bean using ajax

分類Dev

InvalidCastException - passing null values to stored procedure

分類Dev

BOOST_SCOPE_EXIT passing arguments as values

分類Dev

Passing props from grandchildren to parent

分類Dev

Passing Data from Service to Component

分類Dev

Passing a variable from a function to an if statement

Related 関連記事

  1. 1

    Passing values from HTML to SCSS

  2. 2

    Passing values from an Activity into a ListView in another activity and saving these values

  3. 3

    Passing values from controller into javascript in mvc5

  4. 4

    AngularJS Passing changing values from Controller to a Directive Controller

  5. 5

    Passing argument by value to onClick function

  6. 6

    Passing values to a variable

  7. 7

    JavaFX bindings not passing on values

  8. 8

    pytest fixture passing values

  9. 9

    Passing in constructor values into a method?

  10. 10

    Encoding and Passing JSON Object from multiple input values on Create method in Laravel 5.1 Controller

  11. 11

    passing correlated values to a function in Oracle

  12. 12

    Passing form values by id in modal

  13. 13

    Scope of variables and Passing values in java

  14. 14

    Passing multiple values as method parameter

  15. 15

    Passing data from IntentService

  16. 16

    Passing multiple onClick parameters using div.innerHTML

  17. 17

    Passing list of enum values as HTTP query parameters

  18. 18

    Passing list of enum values as HTTP query parameters

  19. 19

    Passing chosen multi select values to controller action

  20. 20

    Passing values directly to setter method using for loop

  21. 21

    Passing Values while handling/calling jQuery event

  22. 22

    Python : passing values between different processes

  23. 23

    Passing Values Between Windows Forms c#

  24. 24

    Passing <p:inputText> values to Bean using ajax

  25. 25

    InvalidCastException - passing null values to stored procedure

  26. 26

    BOOST_SCOPE_EXIT passing arguments as values

  27. 27

    Passing props from grandchildren to parent

  28. 28

    Passing Data from Service to Component

  29. 29

    Passing a variable from a function to an if statement

ホットタグ

アーカイブ