I m new here and in HTML.Well I have to select many values from different areas (eg dropdown list, date input type, time input type etc) and compare them with a table. It select the value right,but it appears only for a sec in the screen and then it disappears!It seems that my Chrome refreshes!This is what i ve done till now..
//inside javascript
function Searching()
{
var a=document.getElementById('movies');
var selMov=a.options[a.selectedIndex].value;
var b=document.getElementById('areas');
var selAr=b.options[b.selectedIndex].value;
var c=document.getElementById('dat').type='date';
var d=document.getElementById("tim").type='time';
var rows=document.getElementById('dataProgram').getElementsByTagName('tr');
document.getElementById("demo").innerHTML=selMov;
}
And i have this <p id="demo"></p> to appear the result.
-
How is the function called?Mike Brant– Mike Brant2013年01月24日 23:12:01 +00:00Commented Jan 24, 2013 at 23:12
1 Answer 1
You are not cancelling the event that triggers the function. So the page is reloading.
You need to return false or call event.preventDefault()
Edit:
based on the comment
<button type="submit" id="but" onclick="Searching(); return false;">Search</button>
5 Comments
Searching()?