• 0

VBScript Concatenating Two Strings + Display Result


Question

Hello I've just started to learn VBScript for one of my classes and am hoping someone here may be able to help me out. I am trying to write a script that will concatenate two strings. The user will type two words, each into a different text box and then click to submit. The script will then join the first and second word together and output the result into a third text box.

My trouble is in displaying the result after concatenating the two words. I am currently unsuccessfully using document.write but really I want to have it display in the third text box.

Any help and advice is appreciated!


<!DOCTYPE HTML>
<HEAD>
<TITLE> Assignment 10 - VBScript </TITLE>
<SCRIPT TYPE="TEXT/VBScript">
<!--
Dim word1, word2, result
Function concatenateWord()
result = word1 & word2
document.write(result)
End Function
-->
</SCRIPT>
</HEAD>
<BODY>
<h3> Please Enter a Minimum of 3 Characters </h3>
<FORM name="myForm" onSubmit="return concatenateWord()">
<TABLE border="0" width="300">
<tr>
<td width="100"> First word: </td>
<td width="200"> <input type="text" id="word1"></td>
</tr>

<tr>
<td width="100"> Second word: </td>
<td width="200"> <input type="text" id="word2"></td>
</tr>
<tr>
<td width="100"> Result: </td>
<td width="200"> <input type="text" id="result"></td>
</tr>
</TABLE>
<TABLE border="0" width="300">
<tr>
<td width="10" align="center">
<INPUT TYPE="SUBMIT" VALUE="Concatenate"></td>
</tr>
</TABLE>
</FORM>
</BODY>
</HTML>
[/CODE]

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

This topic is now closed to further replies.