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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dump div Innerhtml to a form input value

Status
Not open for further replies.

countdrak

Programmer
Jun 20, 2003
358
US
Is it possible to dump a innerhtml into a form value?

I have a div tag with an id.

<div id="productResult"></div>

I want to dump the value into a variable and add it to a url. it just doesn't work!@! I am using prototype.

This is what I do

var s = $('productResult').innerHtml
document.thisform.action = 'myfile.cfm?SKU='+s'

What am I doing wrong?! Thanks guys!
 
Remove the last single quote after the s in your querystring:

Code:
document.thisform.action = 'myfile.cfm?SKU=' + s;


[monkey][snake] <.
 
Also, when I tried it with the dollar sign in front, it failed for me. I had to write it like this:

Code:
var s = ('productResult').innerHtml;
document.thisform.action = 'myfile.cfm?SKU='+s;

and a better way would be:

Code:
var s = document.getElementById('productResult').innerHtml;
document.thisform.action = 'myfile.cfm?SKU='+s;

Ron Wheeler
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top