PDA

View Full Version : PLEASE HELP! Div acting up!



ShadowIce
Nov 27th, 2009, 01:41 PM
How can I make the code tell the webpage whether or not I clicked yes or no? the code i have here wont work. I NEED the yes & no button to remain in the div, there's a reason for that.


<script>
function uninstall(){
if(document.forms.formtest.test1.onClick){
alert('blah!');
}else if(document.forms.formtest.test2.onClick){
alert('naw!');
}else{
alert('fail!');
}
}
function check()
{
document.getElementById("uninstall").innerHTML = "Are you sure? Once you uninstall the database, you will have to reinstall this program.<br><br><input id=\"test1\" type=\"button\" onclick=\"uninstall()\" value=\"Yes\">&nbsp;<input id=\"test2\" type=\"button\" onclick=\"uninstall()\" value=\"No\">";
}
</script>
<a href="javascript:check()">Uninstall Database</a>
<form name="formtest">
<div id="uninstall"></div>
</form>

ANY help is GREATLY appreciated! =)

Thanks! =)

Shadow~

Kor
Nov 27th, 2009, 02:42 PM
Why not using a confirm box?
http://wwwht.w3schools.com/jsref/met_win_confirm.asp

ShadowIce
Nov 27th, 2009, 02:43 PM
Because. I don't want to. Now do you know how to fix this?

Kor
Nov 27th, 2009, 02:57 PM
Because. I don't want to. Now do you know how to fix this?
Not a nice answer. Maybe I don't want to fix that either. To fix what? A wrong and senseless code?

Tell us what precisely you intend to do. In words.

ShadowIce
Nov 27th, 2009, 03:02 PM
I want to be able to click the buttons, and depending on which button they press, I want it to activate an if else statement.

The problem is it NEEDS to be inside a div so it looks like the buttons appear out of nowhere when the user clicks the link.

Kor
Nov 27th, 2009, 03:15 PM
Like this?:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>untitled</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<style type="text/css">
#uninstall{
display:none;
}
</style>
<script type="text/javascript">
function showHide(state){
document.getElementById('uninstall').style.display=state;
}
</script>
</head>
<body>
<a href="#" onclick="showHide('block');return false">Uninstall Database</a>
<form action="">
<div id="uninstall">
Are you sure? Once you uninstall the database, you will have to reinstall this program.
<br><br>
<input type="submit" value="Yes">&nbsp;<input type="button" value="No" onclick="showHide('none')">
</div>
</form>
</body>
</html>

ShadowIce
Nov 27th, 2009, 03:19 PM
Sorta, except when you click one of the buttons, it will display the value for that button. So if you click yes, it will bring up an alert box saying yes.

Kor
Nov 27th, 2009, 03:36 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>untitled</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<style type="text/css">
#uninstall{
display:none;
}
</style>
<script type="text/javascript">
function showHide(state){
document.getElementById('uninstall').style.display=state;
}
function alertValue(obj){
alert(obj.value)
}
</script>
</head>
<body>
<a href="#" onclick="showHide('block');return false">Uninstall Database</a>
<form name="formtest" action="">
<div id="uninstall">
Are you sure? Once you uninstall the database, you will have to reinstall this program.
<br><br>
<input type="button" value="Yes" onclick="alertValue(this)">&nbsp;<input type="button" value="No" onclick="showHide('none');alertValue(this)">
</div>
</form>
</body>
</html>

ShadowIce
Nov 27th, 2009, 03:52 PM
PERFECT! Thank you, Kor! =D

Please accept this thank you as a token of my gratitude! =)