function call outside of jQuery
Hi Community,
i write this function:
- $(function() {
- // Array erstellen
- $.get("hallen.xml",{},function(xml){
- $('address',xml).each(function(i) {
- aHalle[$(this).find("nummer").text()] = new Array();
- aHalle[$(this).find("nummer").text()]["Nummer"] = $(this).find("nummer").text();
- aHalle[$(this).find("nummer").text()]["Halle"] = $(this).find("halle").text();
- aHalle[$(this).find("nummer").text()]["Strasse"] = $(this).find("strasse").text();
- aHalle[$(this).find("nummer").text()]["PLZ"] = $(this).find("PLZ").text();
- aHalle[$(this).find("nummer").text()]["Ort"] = $(this).find("Ort").text();
-
- $('<option value="' + aHalle[$(this).find("nummer").text()]["Nummer"] + '">' + aHalle[$(this).find("nummer").text()]["Halle"]+ '</option>').appendTo('#halle');
- $('<option value="' + aHalle[$(this).find("nummer").text()]["Nummer"] + '">' + aHalle[$(this).find("nummer").text()]["Nummer"]+ '</option>').appendTo('#hallenr');
- });
- });
- function selectOnChange(ref, id) {
- reset();
- if (id==null)
- HallenID = $("#" + ref + " option:selected").val();
- else
- HallenID = id;
- if (HallenID != "00") {
-
- if (ref == "halle") {
- $("#hallenr option[value='" + HallenID +"']").attr('selected','selected');
- } else {
- $("#halle option[value='" + HallenID +"']").attr('selected','selected');
- }
-
- $("#address").hide(0);
- $('.address').remove();
-
- Address = aHalle[HallenID]["Strasse"] + ', ' + aHalle[HallenID]["PLZ"] + ' ' + aHalle[HallenID]["Ort"];
- MapHTML = '<strong>' + aHalle[HallenID]["Halle"]+ ' #' + aHalle[HallenID]["Nummer"] + '</strong><br /><p style="line-height: 2em;">' + aHalle[HallenID]["Strasse"] + '<br />' + aHalle[HallenID]["PLZ"] + ' ' + aHalle[HallenID]["Ort"] + '<br /><a href="#" onclick="initRoute()">Rountenplaner</a></p>';
- AddressHTML = '<p class="address"><strong>' + aHalle[HallenID]["Halle"] + ' #' + aHalle[HallenID]["Nummer"] + '</strong></p><p class="address">' + aHalle[HallenID]["Strasse"] + '<br />' + aHalle[HallenID]["PLZ"] + ' ' + aHalle[HallenID]["Ort"] + '</p>';
- TitelMapHTML = aHalle[HallenID]["Halle"]+ ' #' + aHalle[HallenID]["Nummer"];
- $('#addressHead').after(AddressHTML);
- $("#address").show("slow");
- searchAddress(Address);
- }
- };
- $("#halle").change(function() { selectOnChange("halle",null) }); // Eventhandler SELECT #HALLE
- $("#hallenr").change(function() { selectOnChange("hallenr",null) }); // Eventhandler SELECT #HALLENR
- $("#sidebartoggle").click( function() { // Eventhandler SIDEBAR
- $("#sidebar").toggle(0);
- var show = (flip++ % 2 == 0);
-
- if(show) {
- $("#map").css("width", "780px");
- $("#sidebartoggle").text('Sidebar ausklappen');
- } else {
- $("#map").css("width", "510px");
- $("#sidebartoggle").html('Sidebar einklappen');
- }
-
- });
- $("#routenplanerstart").click(initRoute);
- $(".routenplanerstart").click(initRoute);
- reset();
- });
and this function is located in main.js.
Now i would like call the function in
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
- <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
- <head>
- <title>Saarland Sporthallen</title>
- <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
- <link rel="stylesheet" type="text/css" href="./css/reset.css">
- <link rel="stylesheet" type="text/css" href="./css/style.css">
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
- <script type="text/javascript" src="http://www.google.com/jsapi?key=ABC"></script>
- <script type="text/javascript" src="./js/main.js"></script>
- <script type="text/javascript">
- selectOnChange("halle","02")
- </script>
- </head>
There is following error:
selectOnChange is not defined
Can someone help me?
Best regards
Klaus