ΚΑλησπέρα,
με τον παρακάτω κώδικα δημιουργώ μια φόρμα με javascript.
Ενώ ρυθμίζω όλες οι τιμές κανονικά, δεν μπορώ να ρυθμίσω το default value του input text. H φόρμα εμφανίζεται κανονικά όπως τη θέλω, αλλά ενώ έχω ρυθμίσει το value του input text με setAttribute('value',"defaultname") μου το εμφανίζει κενό. Καμμιά ιδέα ??< 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);
Εμφάνιση 1-3 από 3
-
15-05-10, 23:07 πρόβλημα με ρύθμιση του input text value μιας form που δημιουργώ με javascript #1and now, what ??
-
15-05-10, 23:24 Απάντηση: πρόβλημα με ρύθμιση του input text value μιας form που δημιουργώ με javascript #2
Γιατί καταλάθος σου έχει ξεφύγει κάτι στο 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
-
15-05-10, 23:55 Απάντηση: πρόβλημα με ρύθμιση του input text value μιας form που δημιουργώ με javascript #3
λολ. εντάξει ζαλίστηκα, γράφω πόση ώρα κώδικα.. time for a break..
Thanks!and now, what ??
Bookmarks