magictouch
05-07-2016, 02:18 AM
Hi, I'm a beginner and autodidact in programming so need your patience because for me it is still hard to understand many things...
I'm trying to do a form with 2 option, if the person choose "Massage" I what it to open one file and if the person choose the option "Rencontres" I want the other file with other form to open.
But of course the way I'm trying is not working, of course because still don' t know that much about javascript. So I have no idea where is the error and I've seen many tutorials even so I don't know what to do.
If someone can do the charity of point what I could to to obtain the result I what I will be grateful.
Here is my code, hope you understand what I'm saying.
<!DOCTYPE html>
<html>
<head>
<script>
function populate(s1,s2){
var s1 = document.getElementById(s1);
var s2 = document.getElementById(s2);
s2.innerHTML = "";
if(s1.value == "Massage"){
var optionArray = ["formulaire.php|formulaire.php"];// I'm putting the file I want to open on the iframe here, maybe is ridiculous what I did?
} else if(s1.value == "Rencontres"){
var optionArray = ["|","formulairerencontres.php|formulairerencontres.php"];
}
for(var option in optionArray){
var pair = optionArray[option].split("|");
var newOption = document.createElement("option");
newOption.value = pair[0];
newOption.innerHTML = pair[1];
s2.options.add(newOption);
}
}
</script>
</head>
<body>
<h2>Choisi oł tu veux publier ton annonce:</h2>
<hr />
Choose Car Make:
<select id="slct1" name="slct1" onchange="populate(this.id,'slct2')">
<option value=""></option>
<option value="Massage">Massage</option>
<option value="Rencontres">Rencontres</option>
</select>
<hr />
<iframe id="slct2" name="slct2" width="560" height="315" src="function populate(s1,s2)" frameborder="0"></iframe>// I wanted to open the files formulaire.php and formulairerencontres.php here, Something is wrong here but I have no idea what.
<hr>
</body></html>
To be honest I even don't know if I can do what I want with this code, but I'm open to learn also please help me, it is not ease learn alone only withe the tutorials and with not much time.
Thanks, and hope have answers.
I'm trying to do a form with 2 option, if the person choose "Massage" I what it to open one file and if the person choose the option "Rencontres" I want the other file with other form to open.
But of course the way I'm trying is not working, of course because still don' t know that much about javascript. So I have no idea where is the error and I've seen many tutorials even so I don't know what to do.
If someone can do the charity of point what I could to to obtain the result I what I will be grateful.
Here is my code, hope you understand what I'm saying.
<!DOCTYPE html>
<html>
<head>
<script>
function populate(s1,s2){
var s1 = document.getElementById(s1);
var s2 = document.getElementById(s2);
s2.innerHTML = "";
if(s1.value == "Massage"){
var optionArray = ["formulaire.php|formulaire.php"];// I'm putting the file I want to open on the iframe here, maybe is ridiculous what I did?
} else if(s1.value == "Rencontres"){
var optionArray = ["|","formulairerencontres.php|formulairerencontres.php"];
}
for(var option in optionArray){
var pair = optionArray[option].split("|");
var newOption = document.createElement("option");
newOption.value = pair[0];
newOption.innerHTML = pair[1];
s2.options.add(newOption);
}
}
</script>
</head>
<body>
<h2>Choisi oł tu veux publier ton annonce:</h2>
<hr />
Choose Car Make:
<select id="slct1" name="slct1" onchange="populate(this.id,'slct2')">
<option value=""></option>
<option value="Massage">Massage</option>
<option value="Rencontres">Rencontres</option>
</select>
<hr />
<iframe id="slct2" name="slct2" width="560" height="315" src="function populate(s1,s2)" frameborder="0"></iframe>// I wanted to open the files formulaire.php and formulairerencontres.php here, Something is wrong here but I have no idea what.
<hr>
</body></html>
To be honest I even don't know if I can do what I want with this code, but I'm open to learn also please help me, it is not ease learn alone only withe the tutorials and with not much time.
Thanks, and hope have answers.