PDA

View Full Version : Easy but essential


gildash2
04-14-2004, 07:15 PM
<form name="form1" action="">
Define Dominant Trait(Ex: F):<input type="text" name="dominant" size="2"><Br>
Define Recessive Trait(Ex: f):<input type="text" name="recessive" size="2"><Br>
First Parent:<input type="text" name="text1" maxlength="2" size="2"><br>
Second Parent:<input type="text" name="text1a" maxlength="2" size="2"><br>
<font size="1pt" id="a1" style="position:absolute; top:75; left:200">x</font>
<font size="1pt" id="a2" style="position:absolute; top:75; left:275">x</font>
<font size="1pt" id="b1" style="position:absolute; top:100; left:175">x</font>
<font size="1pt" id="b2" style="position:absolute; top:175; left:175">x</font>
<input type="button" onClick="compile()" value="click">
<script language="javascript">
function compile()
{
var it=document.form1.text1.value;
var it2=document.form1.text1a.value;
document.getElementById('a1').innerHTML=it.substring(0,1);
document.getElementById('a2').innerHTML=it.substring(1,2);
document.getElementById('b1').innerHTML=it2.substring(0,1);
document.getElementById('b2').innerHTML=it2.substring(1,2);
if(it.substring(0,1) || it.substring(1,2) || it2.substring(0,1) || it2.substring(1,2) == "")
{
alert('You must fill out all of the alelles in order to complete the process');
}
}
</script>
the alert is appearing even if the strings in the text boxes are filled, please help me :) thank you

Kram
04-14-2004, 07:21 PM
Sorry if i am in the wrong ball park here but i think that your if statement is wrong, it should be more like this:


if(it.substring(0,1) == "" || it.substring(1,2) == "" || it2.substring(0,1) == "" || it2.substring(1,2) == "")


otherwise the first if check will be true if anything is in it. Give it a try see if it works

gildash2
04-14-2004, 07:44 PM
lol thanks works like a charm :) dang javascript, it should mold tofit my needs!! lol

Kram
04-14-2004, 07:46 PM
np :P