dedon Posted March 4, 2006 Share Posted March 4, 2006 the problem is that what ever i choose it allway say natwest and it always tally up natwest and not the ones u click on look at highlighted part below <html><HEAD><META httP-equiv="content-type" content="text/html;charset=iso 8859-1"/><TITLE>template</TITLE><script language = "javascript">var NatwestCount; var HalifaxCount; var HsbcCount; var AbbeyCount; NatwestCount = 0 HalifaxCount = 0 HsbcCount = 0 AbbeyCount = 0 function disp_ConfirmNatwest() { var Natwest=confirm("You Are Voting For Natwest, Is This Ok?") if (Natwest==true) { NatwestCount = NatwestCount + 1; } else { NatwestCount = NatwestCount + 0; } } function disp_ConfirmHsbc() { var Hsbc=confirm("You Are Voting For Hsbc, Is This Ok?") if (Hsbc==true) { HsbcCount = HsbcCount + 1; } else { HsbcCount = HsbcCount + 0; } } function disp_ConfirmHalifax() { var Halifax=confirm("You Are Voting For Halifax, Is This Ok?") if (Halifax==true) { HalifaxCount = HalifaxCount + 1; } else { HalifaxCount = HalifaxCount + 0; } } function disp_ConfirmAbbey() { var Abbey=confirm("You Are Voting For Abbey, Is This Ok?") if (Abbey==true) { AbbeyCount = AbbeyCount + 1; } else { AbbeyCount = AbbeyCount + 0; } } function disp_alert() { alert (' Total Votes For Each Bank ' + '\n' + ' Natwest = ' + NatwestCount + '\n' + ' Hsbc = ' + HsbcCount + '\n' + ' Halifax = ' + HalifaxCount + '\n' + ' Abbey = ' + AbbeyCount) } function password (form) { var pass = form.inputbox.value; if (pass == "banker") { disp_alert(); } else { alert (" You Have Entered The Wrong Password !!!" + '\n' + " Please Enter The Correct Password") } } </script></head><body><form><select> <option value ="0">Please Choose</option> <option value ="Natwest">Natwest</option> <option value ="Abbey">Abbey</option> <option value ="HSBC">HSBC</option></select><input type="button" value="SUBMIT" onclick="disp_ConfirmNatwest()", <BR> </form> <form name="passform" ACTION="" METHOD="GET">Password: <input type="password" NAME="inputbox" VALUE=""><P> <input type="button" NAME="button" Value="admin view data" onClick="password(this.form)"> </form></script></head><body></body></html> Link to comment Share on other sites More sharing options...
scott100 Posted March 4, 2006 Share Posted March 4, 2006 <input type="button" value="SUBMIT" onclick="disp_ConfirmNatwest()", You are only ever calling one function, you will have to pass the value of the select menu to a function that checks the value and then uses a control structure. <html><HEAD><META httP-equiv="content-type" content="text/html;charset=iso 8859-1"/><TITLE>template</TITLE><script language = "javascript">var NatwestCount; var HalifaxCount; var HsbcCount; var AbbeyCount; NatwestCount = 0 HalifaxCount = 0 HsbcCount = 0 AbbeyCount = 0 function disp_Confirm(val){if (val=="Natwest"){ var Natcheck=confirm("You Are Voting For Natwest, Is This Ok?") if (Natcheck==true) { NatwestCount = NatwestCount + 1; } else { NatwestCount = NatwestCount + 0; } }else if(val=="Abbey"){ var Abbeycheck=confirm("You Are Voting For Abbey, Is This Ok?") if (Abbeycheck==true) { AbbeyCount = AbbeyCount + 1; } else { AbbeyCount = AbbeyCount + 0; }}else if(val=="HSBC"){ var Hsbccheck=confirm("You Are Voting For Hsbc, Is This Ok?") if (Hsbccheck==true) { HsbcCount = HsbcCount + 1; } else { HsbcCount = HsbcCount + 0; } }else alert("Error has occurred");} function disp_alert() { alert (' Total Votes For Each Bank ' + '\n' + ' Natwest = ' + NatwestCount + '\n' + ' Hsbc = ' + HsbcCount + '\n' + ' Halifax = ' + HalifaxCount + '\n' + ' Abbey = ' + AbbeyCount) } function password (form) { var pass = form.inputbox.value; if (pass == "banker") { disp_alert(); } else { alert (" You Have Entered The Wrong Password !!!" + '\n' + " Please Enter The Correct Password") } } </script></head><body><form><select name="payment" id="payment"> <option value ="0">Please Choose</option> <option value ="Natwest">Natwest</option> <option value ="Abbey">Abbey</option> <option value ="HSBC">HSBC</option></select><input type="button" onclick="disp_Confirm(payment.value)" value="SUBMIT" /><BR> Password: <input type="password" NAME="inputbox" VALUE=""><P> <input type="button" NAME="button" Value="admin view data" onClick="password()"> </form></body></html> Link to comment Share on other sites More sharing options...
Webworldx Posted March 4, 2006 Share Posted March 4, 2006 And take out things like: else { NatwestCount = NatwestCount + 0; } As it's not needed Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now