PDA

View Full Version : Variables in HTML form - assigning input type



tvulucy
06-Oct-2004, 09:32 AM
Hello again

We are passing four variables to the form from our database, which are picked up and used in the form like this:


<td>Location</td>
<td>
<%
String temp__location="";
temp__location = request.getParameter("location");
out.println(temp__location);
%>
</td> These values are appearing on the form page OK, but I don't know how to assign them an input type to pass them to formmail. They need to appear in the email with all the other (user entered) fields.

Thanks again for your help

russellr
06-Oct-2004, 08:00 PM
Hi,

That code between the "<%" and "%>" is Java, correct?

What I suggest is that you do this (I'm not sure of the Java syntax, but you should get the idea):



td>Location</td>
<td>
<%
String temp__location="";
temp__location = request.getParameter("location");
out.println(temp__location);
out.println('<input type="hidden" name="location" value="' + temp_location + '" />');
%>
</td>


That creates a hidden field on the form. That get's passed to FormMail with all the other values on the form.

tvulucy
07-Oct-2004, 03:54 PM
Hi Russell

I eventually sussed it.

Catch the variable:
<%
String temp_location="";
temp_location=request.getParameter("location");
%> Then use it in the input type:
<input type="hidden" name="location" value="<%=temp_location%>">
No need for println!

Thanks
Lucy

tvulucy
28-Oct-2004, 02:44 PM
Hi Russell, hope you had a good weekend.

I've resurrected this thread as we're having some problems with the variables

(I know this is a bit cheeky as it's not really part of formmail, so you are welcome to say you aren't able to assist!)

Sometimes (about 1 in 4 emails) the variables are not being passed to the email and appear as 'null' in the HTML email output. All other manually entered values are carried across fine. Unfortunately I have been unable to replicate the problem from my PC, despite trying different browsers, reloading and bookmarking the page etc.

Have you come across anything like this before?

Thanks again
Lucy

russellr
28-Oct-2004, 09:03 PM
Hi,



hope you had a good weekend

Thanks, but actually, it's just about start.

For the problem you're describing, I haven't come across it before. But here are some ideas....

Is it always the same fields/variables? Are these fields towards the end of the form? Thinking: size of data issue. If you're using the POST method, then that should not be a problem.

Are these hidden fields? If so, then you can view the source of the HTML page and verify that the values are correct and properly formatted.

In particular, if the ASP or Java that you're using happens to put in a double-quote character, that will break the HTML and screw up the rest of the form data.