We help IT Professionals succeed at work.
Get Started

HowTo Pass Javascript back into onclick value on ASP page

323 Views
Last Modified: 2012-05-09
Working on logic for an ASP page.
I have a form (myForm) that I want to auto update fields as the user completes the form.

I have a radio button (myRadio) that successfully assigns a variable to a hidden field. (myTempField)
This is where i get 'fuzzy'
Then I have a javascript method (scrapeTempField) to handle variable assignment for a dropdown (Choose) selection.

for the onChange event for the dropdown, I want to grab the hidden field's value
assign it to a new javascript variable; append value with text (extraText)
and then pass that JavaScript variable
BACK
to a visible text field (myTarget) for the user to verify or modify by typing.
before pressing submit to write the combined string to a data source

Ive almost got it but missing the appending piece before forcing it into the textfield
(no server roundtrips please)

thanks for your help !



<%
'
Response.Write "<form name='myForm' action=select.asp method=post>"
'
Response.Write "MyLabel:<input type='radio' value='MyRadioSelection' name='myRadio' id='myRadio' onClick=""document.forms[0].myTempField.value='"myValue"';""> &nbsp;&nbsp;"
'
Response.Write "<input type='hidden' name='myTempField' id='myTempField' value='' />"
'
%>
<script type="text/javascript">
<!--
function scrapeTempField() {
jstemp = document.forms[0].temp.value;
// not sure about this block's logic
return jstemp;
}
//-->
</script>
<%
'
Response.Write "<Select NAME='Choose'>"
Response.Write "<option value='begin'>Select Option</option>"
Response.Write "<option value='option1' onClick=""document.forms[0].myTarget.value='"  & "extraText';"">extraText</option>"
Response.Write "</SELECT>"
'
'
Response.Write "Description: <input name='myTarget' id='desc' type=text size=40 >"
'
'housekeeping
Response.Write "</form>"
Response.Write "<input type=submit value='USE >"
%>

Open in new window

Comment
Watch Question
IT Expert
CERTIFIED EXPERT
Top Expert 2009
Commented:
This problem has been solved!
Unlock 1 Answer and 16 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE