Kirjautuminen

Haku

Tehtävät

Keskustelu: Nettisivujen teko: Javascript lomake ja Firefox ongelma

painajainen [23.02.2011 22:25:42]

#

Hei, en ole koodaaja mutta ymmärrän pätkän sieltä täältä ja googlella olen pärjäillyt. Mistäköhän johtuu että Firefox näyttää aluksi pelkän templaten tässä lomakkeessa(yhdistelty: triple drop down, add input fields ja extending form), toimii anteeksi antavimmilla selaimilla (safari).

Toinen kysymys: Olisiko kellään ehdotuksia kuinka toteuttaa tuotteiden loppusumma laskuri kyseiseen lomakkeeseen?

Kolmas kysymys: Mikä olisi paras tapa suojautua spam botteja vastaan tässä lomakkeessa ja onko mahdollista lähettää lomakkeen tiedot liitteineen sähköpostiini?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
       var counter = 0;

            function moreFields() {
                counter++;
                var newFields = document.getElementById("readroot").cloneNode(true);
                newFields.id = '';
                newFields.style.display = 'block';
                var newField = newFields.childNodes;
                for (var i=0;i<newField.length;i++) {
                    var theName = newField[i].name;
                    if (theName)
                        newField[i].name = theName + counter;
                }
                var insertHere = document.getElementById("writeroot");
                insertHere.parentNode.insertBefore(newFields,insertHere);
            }

            window.onload = moreFields;



/*
Triple Combo Script Credit
By Philip M: http://www.codingforums.com/member.php?u=186
Visit http://javascriptkit.com for this and over 400+ other scripts
*/

var categories = [];
categories["startList"] = ["Käyntikortti","Flyer"]
categories["Käyntikortti"] = ["300 kpl","500 kpl","750 kpl","1000 kpl"];
categories["Books"] = ["Biography","Fiction","Nonfiction"];
categories["Men"] = ["Shirts","Ties","Belts","Hats"];
categories["Women"] = ["Blouses","Skirts","Scarves", "Hats"];
categories["Children"] = ["Shorts", "Socks", "Coats", "Nightwear"];
categories["Biography"] = ["Contemporay","Historical","Other"];
categories["Fiction"] = ["Science Fiction","Romance", "Thrillers", "Crime"];
categories["Nonfiction"] = ["How-To","Travel","Cookbooks", "Old Churches"];

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

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

function getValue(L4, L3, L2, L1) {
alert("Your selection was:- \n" + L1 + "\n" + L2 + "\n" + L3 + "\n" + L1);
}

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

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

</script>
<script type="text/javascript" src="addInputFields.js"></script>
</head>

<body>
<div id="readroot" style="display: none">

	<input type="button" value="Poista lomake"
		onclick="this.parentNode.parentNode.removeChild(this.parentNode);" /><br /><br />

<form name="tripleplay" action="">
<select name='List1' onchange="fillSelect(this.value,this.form['List2'])">
<option selected>Tuote/koko</option>
</select>
&nbsp;
<select name='List2' onchange="fillSelect(this.value,this.form['List3'])">
<option selected>Määrä</option>
</select>
&nbsp;
<select name='List3' onchange="fillSelect(this.value,this.form['List4'])">
<option selected>Make a selection</option>
</select>
&nbsp;
<select name='List4' onchange="getValue(this.value, this.form['List3'].value,
this.form['List2'].value, this.form['List1'].value)">
<option selected >Make a selection</option>
</select><br /><br />
<a href="#" id="imageUpload"><input type="file" name="imageName_1" id="1" /></a>


</div>

        <form method="post" action="/cgi-bin/show_params.cgi">

            <span id="writeroot"></span><br /><br />

            <input type="button" onclick="moreFields()" " value="Tilaan lisää" />
            <input type="submit" value="Lähetä tilaus" />

</form>

</body>
</html>

Vastaus

Aihe on jo aika vanha, joten et voi enää vastata siihen.

Tietoa sivustosta