stretched2thin has asked for the wisdom of the Perl Monks concerning the following question:

hey - when a user submits a form, sometimes a carriage return is inserted with the value from a checkbox/radio button - anyone know why? this could help me avoid writing a regex to combat it...

Replies are listed 'Best First'.
(Ovid) Re: browser sending random info
by Ovid (Cardinal) on Dec 14, 2001 at 02:56 UTC

    Have you tried to 'view source' on the HTML? If your value has a line break...

    Post the relevant HTML and the relevant Perl code.

    Cheers,
    Ovid

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Re: browser sending random info
by andye (Curate) on Dec 14, 2001 at 19:48 UTC
    I agree with Ovid that it sounds like an HTML problem, but you could always chomp the values.

    That way if there is a carriage return at the end, it'll get deleted, and if not, nothing will be altered.

    hth,
    andy.

      i chomped the values and it didn't help, then ovid, i checked the html, and turns out it was my own dumb fault- it was in the regex i used: @elements = split(/\|+/,$myvar); reading then writing back to a text file looking like this: 0|0|0|0 i should have used this: @elements = split(/\|/,$myvar); thanks though! is there a place in here when i could post potentially useful code bits for those seeking to accomplish the same thing i was doing? i was creating a simply survey.cgi to keep track of people's responses to a web poll.
        Hi stretched2thin - glad it worked out.

        is there a place in here when i could post potentially useful code bits for those seeking to accomplish the same thing i was doing?

        Snippets

        andy.