Hi NetWallah,

Really appreciate this! I have adjusted the input as suggested but still no luck.

I am currently pulling the parameter like this as previously suggested:

my $selectedName = param($unit_name);

Here is the current state of my while loop which is able to dynamically create buttons on the page but when clicking on them the page simply refreshes and no parameters are sent through:

my $statement2 = "select unit_name from unitNamesTable"; my $sth = $dbh->prepare($statement2); $sth->execute(); while (my @data = $sth->fetchrow_array()) { $unit_name = $data[0]; push(@unitNames, $unit_name); print "<td>$unit_name<br>"; print "<input type='hidden' name=unit_name value='$unit_name'> +"; print "<input type='image' name='$unit_name' id='$unit_name' a +lt=airConButton src='../../images/unit.jpg' height='100px' width='100 +px' onclick='document.forms[0].unit_name.value =\"$unit_name\";this.f +orm.submit()'></input>"; }

Here are my current URL paramters:

ViewUnits.pl?unit_name=Air+Con+1&Air+Con+1.x=68&Air+Con+1.y=24&unit_name=Air+Con+2&unit_name=Air+Con+3&unit_name=Air+Con+4&unit_name=Air+Con+5&unit_name=Air+Con+6&unit_name=Air+Con+7&unit_name=Air+Con+8&unit_name=Air+Con+9

When putting the hidden input field after the while loop, the URL parameters will always equal "Air Con 9" yet the value still does not display when attempting to print:

    print "<br>Name: $selectedName<br>";

If you need anything else from me or have any other suggestions please let me know. I will continue to research and update if I am able to find a solution!

UPDATE: After playing around with the cgi I have found when setting: $selectedName = param('unit_name'); This links to the hidden input field, button clicks now make the selectedName variable equal "Air Con 1" regardless of which button is pressed. Still not creating the names as expected but at least I am passing a value now.


In reply to Re^4: Passing perl variable as input name? by RobRobson
in thread Passing perl variable as input name? by RobRobson

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.