HTML::Template Select Retrievel of selected value 
Author Message
 HTML::Template Select Retrievel of selected value

I am trying to troubleshoot why I am unable to retrieve the selected
value back from an HTML Select. I can see the id,name values in the
select when I view source, but I noticed that the name of the select
is missing. Where am I going wrong in my code below. I have two
Select's that are dynamic using DB data and one that is hardcoded with
values of yes and no. The hardcoded one works fine. I am able to get
it value and right it back to the table using insert and update
statements. I am using Perl, Perl DBI, CGI, HTML::Template, and mySQL.

*******Retrieve Values***************
my ($AdSource_Select) = param("adsource_select");
my ($AcType_Select) = param("actype_select");
my ($CurrentCustomer) = param("currentcustomer");

************Insert in the table******************8
  my $ins=$mydbi->prepare("INSERT INTO CUSTOMER
(COMPANY,LAST_NAME,FIRST_NAME,PHONE,FAX,EMAIL,URL,ADDRESS1,ADDRESS2,CITY,STATE,ZIP,COUNTRY,SECURITY_QUESTION,SECURITY_ANSWER,NOTES,ADVERTISING_SOURCE_ID,ACCOUNT_TYPE_ID,CURRENT_CUSTOMER,DATE_STARTED)
VALUES ('$Company','$LastName','$FirstName','$Phone','$Fax','$Email','$URL','$Address1','$Address2','$City','$State','$Zip','$Country','$SecurityQuestion','$SecurityAnswer','$Notes',$AdSource_Select,$AcType_Select,'$CurrentCustomer','$DateStarted')");

   $ins->execute() or  "Unable to execute query: $mydbi->errstr\n";

*********Update the table**************
   my $updsource=$mydbi->prepare("UPDATE CUSTOMER SET
COMPANY='$Company',LAST_NAME='$LastName',FIRST_NAME='$FirstName',PHONE='$Phone',FAX='$Fax',EMAIL='$Email',URL='$URL',ADDRESS1='$Address1',ADDRESS2='$Address2',CITY='$City',STATE='$State',ZIP='$Zip',COUNTRY='$Country',SECURITY_QUESTION='$SecurityQuestion',SECURITY_ANSWER='$SecurityAnswer',NOTES='$Notes',ADVERTISING_SOURCE_ID=$AdSource_Select,ACCOUNT_TYPE_ID=$AcType_Select,CURRENT_CUSTOMER=$CurrentC
stomer,DATE_STARTED='$DateStarted' WHERE CUSTOMER_ID=$CustomerId");

   $updsource->execute or die "Unable to execute query:
$mydbi->errstr\n";

   my $rc = $updsource->rows;

   if ($updsource->rows == 0)
   {
      return 0;
   }
   elsif ($updsource->rows == 1)
   {
      return 1;
   }



Sat, 24 Sep 2005 04:06:25 GMT  
 HTML::Template Select Retrievel of selected value
This is a bit confusing. You have two types of select (from HTML and
from the DB) and you have two to three kinds of sources (HTML, perl,
SQL). Your excerpt is a bit short to figure everything out, but maybe I
can help with some tips.

1) on HTML->perl: For testing purposes, I like to use the 'GET' type of
an HTML-action, because then I know, which parameters are send to my
perl program. Can you print out the AdSource_Select... values?

2) Where the selects are coming from doesn't matter. As long as they are
in your HTML source (and not in some kind of fancy javascript) they
behave the same, since your browser doesn't know, who the page created.
Did you look at the HTML-source from within the browser?

3) Does your query crash? I recognized, that you're not using ticks
around $AdSource_Select ... Is this by purpose? I would change the
$ins->execute() or "Unable to execute quere..." to
$ins->execute() or die "Unable to ...

In general, I think, this is not a module question but something for
comp.lang.perl.misc .

Regards,

Heiko

Quote:

> I am trying to troubleshoot why I am unable to retrieve the selected
> value back from an HTML Select. I can see the id,name values in the
> select when I view source, but I noticed that the name of the select
> is missing. Where am I going wrong in my code below. I have two
> Select's that are dynamic using DB data and one that is hardcoded with
> values of yes and no. The hardcoded one works fine. I am able to get
> it value and right it back to the table using insert and update
> statements. I am using Perl, Perl DBI, CGI, HTML::Template, and mySQL.

> *******Retrieve Values***************
> my ($AdSource_Select) = param("adsource_select");
> my ($AcType_Select) = param("actype_select");
> my ($CurrentCustomer) = param("currentcustomer");

> ************Insert in the table******************8
>   my $ins=$mydbi->prepare("INSERT INTO CUSTOMER
> (COMPANY,LAST_NAME,FIRST_NAME,PHONE,FAX,EMAIL,URL,ADDRESS1,ADDRESS2,CITY,STATE,ZIP,COUNTRY,SECURITY_QUESTION,SECURITY_ANSWER,NOTES,ADVERTISING_SOURCE_ID,ACCOUNT_TYPE_ID,CURRENT_CUSTOMER,DATE_STARTED)
> VALUES ('$Company','$LastName','$FirstName','$Phone','$Fax','$Email','$URL','$Address1','$Address2','$City','$State','$Zip','$Country','$SecurityQuestion','$SecurityAnswer','$Notes',$AdSource_Select,$AcType_Select,'$CurrentCustomer','$DateStarted')");

>    $ins->execute() or  "Unable to execute query: $mydbi->errstr\n";

> *********Update the table**************
>    my $updsource=$mydbi->prepare("UPDATE CUSTOMER SET
> COMPANY='$Company',LAST_NAME='$LastName',FIRST_NAME='$FirstName',PHONE='$Phone',FAX='$Fax',EMAIL='$Email',URL='$URL',ADDRESS1='$Address1',ADDRESS2='$Address2',CITY='$City',STATE='$State',ZIP='$Zip',COUNTRY='$Country',SECURITY_QUESTION='$SecurityQuestion',SECURITY_ANSWER='$SecurityAnswer',NOTES='$Notes',ADVERTISING_SOURCE_ID=$AdSource_Select,ACCOUNT_TYPE_ID=$AcType_Select,CURRENT_CUSTOMER=$CurrentC
> stomer,DATE_STARTED='$DateStarted' WHERE CUSTOMER_ID=$CustomerId");

>    $updsource->execute or die "Unable to execute query:
> $mydbi->errstr\n";

>    my $rc = $updsource->rows;

>    if ($updsource->rows == 0)
>    {
>       return 0;
>    }
>    elsif ($updsource->rows == 1)
>    {
>       return 1;
>    }



Sat, 24 Sep 2005 15:15:14 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. challence to regex gurus: selecting within selected paragraphs

2. challence to regex gurus: selecting within selected paragraphs

3. IO::Select::select not blocking on a filehandle

4. CGI_Lite & Multi-select SELECT fields

5. CGi.pm: get values from multiple select list

6. CGI.pm: get values from multiple select list

7. XML::XSLT doesn't select correct element based on attribute value

8. How to Process MULTIPLE select values

9. Obtaining Values from Mulitple Selects

10. interogate values from a select multiple?

11. select() return values

12. <SELECT multiple...> only returns 1st value

 

 
Powered by phpBB® Forum Software