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

help w/ setting form field values from an onclick function 2

Status
Not open for further replies.

mopacfan

Programmer
Oct 30, 2000
190
0
0
US
I need to be able to set the form field values of six form fields if the user clicks on "Repeat" so they don't have to re-enter the data in several fields of a large form if the data is repetitive.

This is the javascript I have:

<script language=&quot;javascript&quot;>
<!--//
function showval(a,b,c,d,e,f,g){
document.arttracking.sono.value = a;
document.arttracking.custno.value = b;
document.arttracking.shape.value = c;
document.arttracking.distributor.value = d;
document.arttracking.imprint.value = e;
document.arttracking.artist.value = f;
}
//-->
</script>


I pass six values to the function here: (the values are filled in with asp values)

<a href=&quot;javascript:null(0)&quot; OnClick=&quot;showval(<%=request(&quot;var1&quot;)%>,<%=request(&quot;var2&quot;)%>,<%=request(&quot;var3&quot;)%>,<%=request(&quot;var4&quot;)%>,<%=request(&quot;var5&quot;)%>,<%=request(&quot;var6&quot;)%>);&quot;>Repeat</a>

I get two errors:

line1
char1
object expected

line26
char9
syntax error

----------------

I'm an asp developer and I only dabble in Javascript. Any help will be greatly appreciated.

Thanks
 
I'm assuming the values you're passing are strings. If so, I'd put single quotes around each server variable, like so:

[tt]<a href=&quot;javascript:null(0)&quot; OnClick=&quot;showval('<%=request(&quot;var1&quot;)%>','<%=request(&quot;var2&quot;)%>','<%=request(&quot;var3&quot;)%>','<%=request(&quot;var4&quot;)%>','<%=request(&quot;var5&quot;)%>','<%=request(&quot;var6&quot;)%>');&quot;>Repeat</a>[/tt]

When you pass a value in a javascript function's parameter, and it's not numeric, boolean or object, it must be enclosed by single quotes or you'll get that error, because it's going to try to read the parameter as an object.

HTH,
jp
 
IT WORKS! Thanks a bunch for your help.

Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top