Thursday, May 8, 2008

How to add Alert Box with Prompt field

This is another type of Alert Box but this one will prompt user to enter some information. For instance, the prompt box can ask the reader for his name and use that to customize the web page. Be reminded that many browsers are configured to disable scripts that ask for information. Have fun customizing your Blog but don't make this a key aspect of the contents. For example, if you have a story that keeps mentioning the name of the reader, the parts where the name should be will appear “null”.

► Under the Layout tab select Page Elements and add a HTML/JavaScript page element
► Copy and paste the code below
► Change the line "Enter your message here" with the your own set of message.
► You can also change the line "reader" with your own default value of your text box field.



<script type="text/javascript">
var yourName = prompt("YOUR MESSAGE HERE", "Reader");
</script>


Below this JavaScript, add another HTML/JavaScript page element and enter the code below. this message will be a greeting message for your readers.


Welcome back
<script type="text/javascript"
>
document.write(yourName)
</script>! Feel free to look around.
If you like what you read, mention us in
your post or link to this site.
Hope to see you again
<script type="text/javascript"
>
document.write(yourName)
</script>


note: it is important that you add this java script code below the java script code of the alert box.

0 comments: