Forum Moderators: open

Message Too Old, No Replies

Simple Text Field w/ Alert When Submitted

text field, alert, javascript

         

LaurenAshley

11:34 pm on Jul 17, 2008 (gmt 0)

10+ Year Member



I'm new to javascript and need to have a simple form done right away - am having no luck searching for help on the net...

I need to create a URL when a user enters a string into a text field. When the form is submitted, I'd like an alert to pop up with the full URL in it. The URL would be like follows:

[domain.com...]

Is this possible? I have a list of URL's I need to do this for....

Thanks for any help!

Trace

1:31 pm on Jul 18, 2008 (gmt 0)

10+ Year Member



I typed up a quick example, hope it helps;

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title> New Document </title>
</head>
<body>

<form action="http://www.google.com" method="post" onsubmit="alertUser(document.getElementById('txtString').value);">
<fieldset>
<legend>Url Form</legend>

<label>String</label>
<input type="text" id="txtString">
<input type="submit">

</fieldset>
</form>

<script type="text/javascript">
function alertUser(theValue){
alert('http://www.domain.com/'+theValue);
}
</script>

</body>
</html>