Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a Javascript value to a Classic ASP page

Status
Not open for further replies.

Lladros

Programmer
Feb 21, 2008
18
US
I hope that I can explain this correctly. I am new to Javascript.

I have a Classic ASP page that loads the information from the database. There is a textbox with comments which came from the database. I have a hidden field with those comments value. The user will be able to change those comments in a textbox. I need that hidden field to get populated with the new comments that the user has just entered and then submitted the form.

Is there a way, in Javascript, to get the comments from the textbox and put in the hidden field without refreshing the page?

All your help is greatly appreciated!
 
Is there a way, in Javascript, to get the comments from the textbox and put in the hidden field without refreshing the page?

Yes, but why would you want to do that? Presumably the textbox would exist inside the form that is being submitted. If that is the case, serverside - just have ASP retrieve the value from the textbox instead of the hidden form field.

If you still prefer to use the hidden field method, here is an example:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<script type="text/javascript">

/*<![CDATA[*/

function validate(frm) {
   document.getElementById("h").value = document.getElementById("t").value;
   //let's double check to make sure the value was set correctly
   alert(document.getElementById("h").value);
   return true;
}

/*]]>*/

</script>

<style type="text/css"></style>
</head>

<body>

<form id="f" method="post" onsubmit="return validate(this)">

   <input type="text" id="t" name="t" />
   <input type="submit" value="click me" />
   <input type="hidden" id="h" name="h" />

</form>

</body>
</html>

-kaht

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top