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

Javascript in perl

Status
Not open for further replies.

extempore

Programmer
Jun 1, 2001
71
US
This is a section of the code from my perl script...I wanted to pass the value to a javascript depending on the row clicked. The results gets displayed properly based on the query but the javascript seems to get an undefiened value back when I use the function like this:

while (@returnval = $sth->fetchrow_array())
{
print &quot;<table border=1 align=center width='100%'>\n&quot;;
print &quot;<TR onclick='sendDataToParent(@returnval);'><TD>@returnval</TD></TR>\n&quot;;
print &quot;</table>\n&quot;;
}

Can someone help me how to write javascripts within the print of perl script. Thanks
 
yes the values are displayed correctly but I am trying to send the value depending on the row clicked to the Javascript function but it goes a s undefined for some reason.
 
If you check the source of your HTML, and it looks the way it should (i.e., the @returnval interpolated correctly in BOTH places), then I might guess that it's a javascript thing.

Do there need to be quotes around the argument in the javascript function call?:::
Code:
print qq!<TR onclick='sendDataToParent(&quot;@{returnval}&quot;);'><TD>@returnval</TD></TR>\n!;
Notice the quotes and {} around the @returnval variable. This may help your javascript disambiguate some naked words that are appearing in your script.

It would help if your posted the result of your script after it ran. That would the the source(HTML) of the web page. This would help determine what's going on.

--jim

 
bingo...thanks for ur help .. i included the quote and the {} and it worked...thanks sir.
 
I'm trying to make a perl script respond to user selection from form object radio button value of &quot;Yes&quot; or &quot;No&quot;. That is, if the user selects &quot;Yes&quot;, then the form results will be parsed and user sent to an html page, e.g., &quot;received.html&quot;

If the user selects radiobutton &quot;NO&quot;, completes the remainder of the form and submits, then the user is sent to an html page e.g., &quot;weneedtofollowup.html&quot;

How can I do this in Perl?

I'd started using the following script but realised that the value would use what I have there (No.html and Yes.html) and not values of &quot;Yes&quot; or &quot;No&quot;

<input type=&quot;radio&quot; name=&quot;receipt&quot; value=&quot;No.html&quot; onclick=&quot;document.forms[0].action = this.value&quot; /> ) YES
<br />
<input type=&quot;radio&quot; name=&quot;receipt&quot; value=&quot;Yes.html&quot; onclick=&quot;document.forms[0].action = this.value&quot; /> ) NO

Can someone help? I need this resolved.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top