This Message Forum is no longer in use

Please use the new Bravenet Help Forums FOUND HERE

General Forum
This Forum is Locked
Author
Comment
Basic Javascript Prompt box passing information....

Hi,
I am very new to Javascript and the DOM.
I was working on this here...

html>
head>
title>

script type="text/javascript">
!--
function name(){
Name=prompt("enter name","bob");

if (Name==""||Name==null){
alert("Please enter name!");
name();
}
else {
document.namef.write("Hi" + Name);
}
}
-->
/script>

/head>
body style="background-color:yellow;" onload="name()">

form action="fill/in" name="form1">

input type="text" style="margin-left:40%; background-color:yellow; border:0 solid yellow;" name="namef" value="Your name will go here">
/input>
/form>
/body>
/html>

Simple enough no?
I can't seem to get the Prompt box to pass the Name information to the textfield in the form...
Ideas anyone..
Thanks,
Bo

Re: Basic Javascript Prompt box passing information....

The form has no way of "knowing" that the value is a javascript variable. Use a document.write command to create that part of the form.

Re: Basic Javascript Prompt box passing information....

Hi Peter,
I am passing the prompt box information that is called from the BODY tag. into the INPUT TEXT field named "namef"
I did get this to work but only if I don't use a DTD.
When I use the DTD I get a response of "use the getElementByID-or-Name()".
Hmmmmm.....

Here is the newer version......

html>
head>
title>

script type="text/javascript">
!--
function name(){
Name=prompt("enter name","bob");

if (Name==""||Name==null){
alert("Please enter name!");
name();
}
}
function yername() {

namef.value=("Hi There " + Name);
}
-->
/script>

/head>
body onload="name(); yername()" >

form action="#" id="form1">

p>input type="text" style="margin-left:40%; background-color:yellow; border:1px solid red;" id="namef" />/p>

/form>



/body>
/html>