Εμφάνιση 1-3 από 3
  1. #1
    Εγγραφή
    20-09-2003
    Περιοχή
    Amsterdam
    Μηνύματα
    214
    Downloads
    7
    Uploads
    0
    Τύπος
    Cable
    Ταχύτητα
    60/40
    ISP
    Surfnet
    ΚΑλησπέρα,

    με τον παρακάτω κώδικα δημιουργώ μια φόρμα με javascript.
    < HTML:
    var form=document.createElement("form");
            form.setAttribute('name',"jump");
            form.setAttribute('action',"main.php");
            form.setAttribute('method',"get");
            form.setAttribute('id',"form");
    
            var paragra=document.createElement("p");
            paragra.setAttribute('align',"center");
            paragra.setAttribute('id',"paragra");
    
            var select=document.createElement("select");
            select.setAttribute('name',"menu");
            select.setAttribute('id',"select");
    
            var option1=document.createElement("option");
            option1.setAttribute('value',"1");
            option1.setAttribute('id',"option1");
    
            var optiontext1 = document.createTextNode("Type 1");
    
            var option2=document.createElement("option");
            option2.setAttribute('value',"2");
            option2.setAttribute('id',"option2");
    
            var optiontext2 = document.createTextNode("Type 2 ");
            
            var option3=document.createElement("option");
            option3.setAttribute('value',"3");
            option3.setAttribute('id',"option3");
    
            var optiontext3 = document.createTextNode("Type ");
    
            var inputname=document.createElement("input");
            //EDW EINAI AYTO POY RY8MIZW KAI DEN MOU TO EMFANIZEI
            inputname.setAttribute('value',"Enter your name");
            inputname.setAttribute('onfocus',"value=''");
            inputname.setAttribute('type',"text");
            inputname.setAttribute('name',"name");
    
            var submit=document.createElement("input");
            inputname.setAttribute('value',"Book");
            inputname.setAttribute('type',"submit");
    
            
                
          
            
            document.getElementById("hotelservice").appendChild(service);//append the new row
            document.getElementById("choice").appendChild(table);//append the new data of new row where all the php output will be
           
            document.getElementById("table").appendChild(tablerow1);
            document.getElementById("table").appendChild(tablerow2);
            document.getElementById("row1").appendChild(tabledata1);
            document.getElementById("row2").appendChild(tabledata2);
            
            document.getElementById("data1").appendChild(title);
            
            document.getElementById("data2").appendChild(form);
            document.getElementById("form").appendChild(paragra);
            document.getElementById("paragra").appendChild(select);
            document.getElementById("select").appendChild(option1);
            document.getElementById("select").appendChild(option2);
            document.getElementById("select").appendChild(option3);
            document.getElementById("option1").appendChild(optiontext1);
            document.getElementById("option2").appendChild(optiontext2);
            document.getElementById("option3").appendChild(optiontext3);
            document.getElementById("form").appendChild(submit);
            document.getElementById("form").appendChild(inputname);
    Ενώ ρυθμίζω όλες οι τιμές κανονικά, δεν μπορώ να ρυθμίσω το default value του input text. H φόρμα εμφανίζεται κανονικά όπως τη θέλω, αλλά ενώ έχω ρυθμίσει το value του input text με setAttribute('value',"defaultname") μου το εμφανίζει κενό. Καμμιά ιδέα ??
    and now, what ??

  2. #2
    Εγγραφή
    30-01-2006
    Περιοχή
    SunCity
    Ηλικία
    37
    Μηνύματα
    156
    Downloads
    6
    Uploads
    0
    ISP
    OTEnet
    DSLAM
    ΟΤΕ - ΔΑΦΝΗ
    Router
    Linksys WAG200G
    Γιατί καταλάθος σου έχει ξεφύγει κάτι στο copy paste:

    Αμέσως μετά το inputname πας και φτιάχνεις το submit και εκεί βάζεις πάλι την τιμή του input.

    Άλλαξε αυτό

    Κώδικας:
    var submit=document.createElement("input");
    inputname.setAttribute('value',"Book");
    inputname.setAttribute('type',"submit");
    σε αυτό

    Κώδικας:
    var submit=document.createElement("input");
    submit.setAttribute('value',"Book");
    submit.setAttribute('type',"submit");
    Cloud Connected

  3. #3
    Εγγραφή
    20-09-2003
    Περιοχή
    Amsterdam
    Μηνύματα
    214
    Downloads
    7
    Uploads
    0
    Τύπος
    Cable
    Ταχύτητα
    60/40
    ISP
    Surfnet
    λολ. εντάξει ζαλίστηκα, γράφω πόση ώρα κώδικα.. time for a break..

    Thanks!
    and now, what ??

Tags για αυτό το Θέμα

Bookmarks

Bookmarks

Δικαιώματα - Επιλογές

  • Δεν μπορείτε να δημοσιεύσετε νέα θέματα
  • Δεν μπορείτε να δημοσιεύσετε νέα μηνύματα
  • Δεν μπορείτε να αναρτήσετε συνημμένα
  • Δεν μπορείτε να επεξεργαστείτε τα μηνύματα σας
  •  
  • Τα BB code είναι σε λειτουργία
  • Τα Smilies είναι σε λειτουργία
  • Το [IMG] είναι σε λειτουργία
  • Το [VIDEO] είναι σε λειτουργία
  • Το HTML είναι εκτός λειτουργίας