Jump to content


Check out our Community Blogs

bluefenix

Member Since 13 Aug 2012
Offline Last Active Nov 13 2012 11:07 AM
-----

Posts I've Made

In Topic: [SOLVED] A simple program [alert("Something")]

16 September 2012 - 08:18 PM

I said in my first reply, there are errors in the last else part in the javascript function.

Your code --

else
(
alert("No div selected.");
)

*/ }/*

-which should be --
else {
alert("No div selected.");
}
}


I fix it, I deleted the else and now it works. Thanks.

In Topic: [SOLVED] A simple program [alert("Something")]

16 September 2012 - 07:44 PM

Well, still there are errors in your code. You are missing the start head tag and the head & body should be in the HTML tag. Learn about the basic HTML layout from w3schools.

No, I havent I didnt copied it because its obvious, trust me I know very well HTML and CSS.

When I just reduce the script to this it works:
<script>
function zapatosOne()
{
return alert("Alert");
}
</script>

So I think its something wrong with the way Im using DOM.

In Topic: [SOLVED] A simple program [alert("Something")]

16 September 2012 - 07:28 PM

Ok, post your whole HTML page here. I mean just post all the content of the HTML page you are testing with.


<script>

function zapatosOne()
{
var selectSex= document.getElementById("**").selectedIndex;
var sexS= document.getElementById("**").options[selectSex].text;
var sexB= document.getElementById("**").value;

if (sexS ==="Masculino")
{
/alert("One two three four");
}

else if (sexS ==="Femenino")
{
/alert("Five");
}

else
(
alert("No div selected.");
)


*/ }/*
</script>
</head>

<body>
<div id= "selectContainer">
<form method= 'POST' id="myform">
<div class= "selectDiv">
<label>**</label>
<select id= "**" onchange="zapatosOne()">
<option value="1">Male</option>
<option value="2">Female</option>
</select
</div>
</form>
</div>
</body>

In Topic: [SOLVED] A simple program [alert("Something")]

16 September 2012 - 07:16 PM

There are few problems in your code -- i) the ending 'form' & 'div' tag missing, ii) there is in your javascript code as well (note that you need to put your javascript code in script tag in the html header section.

Corrected HTML code --


<div id="selectContainer">
<form method='POST' id="myform">
<div class="selectDiv">
<label>
**</label>
<select id="**" onchange="zapatosOne()">
<option value="1">Male</option>
<option value="2">Female</option>
</select>
</div>
</form>
</div>


Corrected javascript code --
<script>
function zapatosOne()
{
var selectSex= document.getElementById("**").selectedIndex;
var sexS= document.getElementById("**").options[selectSex].text;
var sexB= document.getElementById("**").options[selectSex].value;

if (sexB =="1") {
alert("One two three four");
}
else if (sexB =="2") {
alert("Five");
}
else {
alert("No div selected.");
}
}
</script>


Thanks for answering. I changed it. But still doesn´t work.

In Topic: A simple program [alert("Something") && checkbox.checked]

13 August 2012 - 12:23 PM

Now it works, thanks a lot. But how will this be without the button, just the checkbox. When the checkbox is checked display an alert:

<div id= "div">

<form id= "row" method= "POST">Dulce/Salado



<input type="checkbox" name="option3" value="International" id= 'inter'> International</input>

</form>
</div>

<script type= "text/javascript">

function f()
{
var inter= document.getElementById("inter");

if (inter.checked== true)
{
alert("Something");
}
}
</script>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download