Jump to content

javascript with if inside if


Yannis

Recommended Posts

I would like to ask about a problem in the following code, inside the second if i don't get back the else condition of command "if".If you may help us we would be very grateful!!Thank you for your time!!

 

<script type="text/javascript">

function displayName(form){
var browsername=window.location.href=="istoria.html";
if (confirm('Time ' +form.wra.value + ' atoma ' + form.atoma.value + ' ' + form.sala.value ) == true) {
if (sala==sala_ble){
window.open("ble sala.html")
}
else if (sala==sala_kafe) {
window.open("kafe sala.html")
}
}else {
x=alert("try again")
}}
</script>
<p>
<select name="sala" id="sala">
<option value="sala_ble">sala_ble</option>
<option value="sala_kafe">sala_kafe</option>
</select>
</p>

 

kratisi.html

Link to comment
Share on other sites

Your code has many errors, and it is a bad idea to use file name that contain spaces. Try...

 

http://validator.w3.org/

 

This version might help you...

<script type="text/javascript">window.onerror = function(a, b, c, d){alert('Javascript Error:n'+a+'nURL: '+b+'nLine: '+c+'  Column: '+d);return true;}</script><script type="text/javascript">'use strict';function displayName(form){	var browsername=(window.location.href=="istoria.html");        alert('browsername = '+ browsername);        var wra = form.wra.value;        var atoma = form.atoma.value;        var sala = form.sala.value;    if (confirm('Time  ' + wra + ' atoma  ' + atoma + '   ' + sala ) == true) {        alert('sala = ['+ sala +']');	if (sala==='sala_ble'){                alert('open ble_sala.html');        	window.open("ble_sala.html");		}	else if (sala==='2')  {                alert('open kafe_sala.html');		window.open("kafe_sala.html");	}    	}else {			alert("try again");}}</script> 
  • Like 1
Link to comment
Share on other sites

You should use your browsers console to look for errors, that would be the first step in debugging any Javascript code.

  • Like 1
Link to comment
Share on other sites

My friend you helped me very much and now using the command if in dreamweaver, the user can change site with a click! Thank's agian for your help and that you answered our message!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...