www.webdeveloper.com
Results 1 to 2 of 2

Thread: get javascipt to send

  1. #1
    Join Date
    Feb 2012
    Posts
    15

    get javascipt to send

    I have three dropdown lists that depends on each and I want to send them to a database, other but when I try to add a php action like action="testar.php?send" it becomes like testar.php?List1=Blekinge+län&List2=Karlshamn&List3=Karlshamn-Centrum&submit=Send
    when I need it to be testar.php?send do any one have any idea gow to solve this?



    <head>

    <script type="text/javascript">

    var categories = [];
    categories["startList"] = ["Blekinge län", "Dalarnas län"];

    categories["Blekinge län"] = ["Karlshamn","Karlskrona","Olofström","Ronneby","Sö lvesborg"];


    categories["Karlshamn"] = ["Karlshamn-Centrum"];
    categories["Karlskrona"] = ["Karlshamn-Centrum"];
    categories["Olofström"] = ["Karlshamn-Centrum"];
    categories["Ronneby"] = ["Karlshamn-Centrum"];



    categories["Dalarnas län"] = ["dalarna1","dalarna2"];

    categories["dalarna1"] = ["dalarna1-Centrum"];
    categories["dalarna2"] = ["dalarna2-west"];





    var nLists = 3; // number of select lists in the set

    function fillSelect(currCat,currList){
    var step = Number(currList.name.replace(/\D/g,"")),i;
    for (i=step; i<nLists+1; i++) {
    document.forms['dummyForm']['List'+i].length = 1;
    document.forms['dummyForm']['List'+i].selectedIndex = 0;
    }
    var nOption,nData,nCat = categories[currCat];
    for (each in nCat) {
    nOption = document.createElement('option');
    nData = typeof(nCat[each])=='string'?nCat[each]:nCat[each][0];
    nOption.setAttribute('value',nCat[each]);
    nOption.appendChild(document.createTextNode(nData) );
    currList.appendChild(nOption);
    }
    }

    function getValue(L3, L2, L1) {
    var CR=String.fromCharCode(10)+String.fromCharCode(12),obj=document.getElementById("info"),s=L3.split(', ' ),txt= L1 + CR+ L2 + CR + L3,z0=1;
    if (s.length>1){
    txt='';
    for (;z0<s.length;z0++){
    txt+=s[z0]+CR;
    }
    }
    obj.innerHTML=txt
    }

    function init() {
    fillSelect('startList',document.forms['dummyForm']['List1'])
    }

    navigator.appName == "Microsoft Internet Explorer" ? attachEvent('onload', init, false) : addEventListener('load', init, false);

    </script>
    </head>
    <body>
    <form name="dummyForm" action="">
    <select name="List1" onchange="fillSelect(this.value,this.form['List2'])">
    <option selected>Välj län</option>
    </select>
    &nbsp;<br />
    <select name="List2" onchange="fillSelect(this.value,this.form['List3'])">
    <option selected>Välj kommun</option>
    </select>
    &nbsp;
    <br />

    <select name="List3" onchange="getValue(this.value, this.form['List2'].value, this.form['List1'].value)" >
    <option selected >Välj </option>
    </select>

    <div id="info">This is the default text</div>






    </form>
    </body>
    </html>

  2. #2
    Join Date
    Jan 2009
    Location
    Insanity
    Posts
    1,131
    add to the form element the value of method="POST" to tell the form to post the data rather than GET the data as your form is using GET to send data via URL and not to the server via POST.

    Also, wrap you code in forum tags please.
    We all have baggage to carry in life, unfortunately for me I always get the trolley with the wonky wheel...
    Code:
    Youre = {
          STILL_not_getting_it:function(){
               alert("YOU, the original poster / thread starter NEED to POST the code and NOT a LINK.");
          },
          MissingThePoint:function(msg){
                alert("You're missing the point. " + msg);
          }
    }
    Youre.STILL_not_getting_it();

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles