im trying to desgin a new web ui for my hp mediavault and right now i am doing the javascript part of the ui.
heres my problem.
im putting a function in to erase the NVRAM, HOWEVER i dont want users to simply be able to click it and clear it without confirmation. i dont like the idea of a simple confirm() box becouse it would be too easy to click ok without thinkign about it, so i want to do this.
function conf()
{
var conf=prompt("WARNING really clear nvram? enter "understand" to continue.")
if (conf =="understand")
{
document.location.href="commandp/nvramclear.asp"
}
else
{
alert("invalid confirm code. ")
}
else if (conf ==null)
{
}
}
now, IF the user enters the confirm code wrong, i want the script to loop back to the top and keep on going until the user enters the correct code. HOWEVER, IF the user clicks cancel (and returns null) i want the script to stop.
ya, that works, I guess javascript doesn't have that goto command rrgh....
Remember don't declare your variable
String temp; // This doesn't work
var temp = new String(); // That's how I would do it but you don't need the 'new String() part it's just the c++ programmer in me :)
Also, with that code you can only type "understand" or else you are in an infinite loop.
__________________
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - My Website
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
I don't believe in atheists therefore atheists don't exist.
ya, that works, I guess javascript doesn't have that goto command rrgh....
Remember don't declare your variable
String temp; // This doesn't work
var temp = new String(); // That's how I would do it but you don't need the 'new String() part it's just the c++ programmer in me :)
Also, with that code you can only type "understand" or else you are in an infinite loop.
ok, well here is my new code.
@star, one of the reasons i am doing this is so i can learn js, your post is a bit too advanced for what i am at now. i will save it however an look at it in a few days, when i can understand it a bit better. unfortunately, i only learned a little bit of js when i was younger, so now i am catching up.
here is my new code:
//this is a special function that prompts a confim code.
function conf()
{
do
{
var conf=prompt("WARNING really clear nvram? enter 'understand' to continue.")
if (conf =="understand")
{
document.location.href="commandp/nvramclear.asp"
}
else
{
alert("invalid confirm code.")
}
}
while (conf !="understand" && conf !=null)
}
the only problem with this is that it you exit, you get the alert message, but i think i can fix that on my own.
sorry for the double post, but i got it working now....
//this is a special function that prompts a confim code.
function conf()
{
do
{
var conf=prompt("WARNING really clear nvram? enter 'understand' to continue.")
if (conf =="understand")
{
document.location.href="commandp/nvramclear.asp"
}
else if (conf !=null)
{
alert("invalid confirm code.")
}
}
while (conf !="understand" && conf !=null)
}
all i added to get it to work was on line 11, i added on to else... with "if (conf !=null)
Why don't you just change the strings in the code?
no, im talking about the strings generated by the device (im working on a new web ui for a embedded file server).
im talking mostly about little things. like for example, the server will generate dhcp_client when quired about the net mode, however, to look nice (and to be short) this needs ot be converted to just plain old "dhcp".
so, i create a variable in my js file that would read "var dhcp_client="dhcp"":)