简体   繁体   中英

Pass method variables in Dreamweaver

I'm building a web program in Dreamweaver that uses Java and I am trying to learn to pass variables between methods. But all the tutorials I look at involve parameters and public class, which for some reason is not being recognized in Dreamweaver, is there another way? How do I do this?

var list = [];

list[0] = [zero]; // USE VARIABLES HERE
list[1] = [one];
list[2] = ["two"];
list[3] = ["three"];

function Make() {
    for (var i = 0; i < 4; i++) {
        var div = document.createElement("div");
        div.style.width = "10px";
        div.style.height = "10px";
        div.style.background = "white";
        div.style.color = "black";
        div.style.top = "0px";
        div.style.left = "0px";
        div.style.margin = "10px 10px auto";
        div.style.cursor = "pointer";
        div.innerHTML = list[i];

        !function() {
            var index = 0;
            div.onclick = function() {
                doSomething(this);
                doEverything(this);
            };
        }();

        document.body.appendChild(div);
    }
}

function doSomething(element) {
    var value = element.innerHTML;
    // alert('clicked : '+ value);
    switch (value) {
    case "zero":

        break;
    case "one":
        //USE VARIABLES HERE
        break;
    case "two":
        alert("go");
        break;
    case "three":
        alert("go");
        break;
    }
}

$(document).ready(function doEverything(element) {
    $.getJSON("https://api.foursquare.com/v2/venues/search?ll=-27.58818,-48.523248&client_id=&client_secret=&v=20111107", function(data) {
        var two = data.response.venues[1].name;
        var one = data.response.venues[0].name;
        // USE THESE VARIABLES
    });
});

Make();

To explain it a little better, javascript is a great, lightweight, web language that is good for creating dynamic web pages. But it is only meant for that. Java is a full-blown object oriented programming language that is capable of writing desktop, mobile, and web programs. Java can also be used for server-side programming. The functions you are reading about with 'public void SomeFuntion()' is Java. What you have in your code is javascript. For what you are doing, javascript is probably what you want if you are writing client-side code but you will need PHP, Cold Fusion, or something else if you are doing any server side programming.

There are many good tutorials around for javascript including many books as well. Two sites that I have used often, especially beginning are tizag and w3schools Both of these, among others, have tutorials for many different languages and I have found them to be pretty informative starting out. Good luck to you!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM