Forum Moderators: phranque

Message Too Old, No Replies

Automatically filling in form fields...

Having certain form fields already filled out depending on referring URL.

         

chowcat

1:40 pm on Sep 10, 2002 (gmt 0)



Hi, could anyone recommend a solution to a minor problem I am encountering. I have an enquiry form that is linked to from about 6 pages of my site. Each of the six pages is themed for six different types of "widget".

If a viewer browsers onto my "red widget" page and then decides to make an enquiry, how do I get the first field of the form to automatically read "red widget", without having to make 6 different forms? I am not really programmer status and I use DW MX to make sites. Effectively removing the need to select “red widget” from a drop down is what I am trying to achieve.

Any suggestions?
Thanks.

threecrans

2:05 pm on Sep 10, 2002 (gmt 0)

10+ Year Member



I have a similar setup in ASP and I pass the values in with a querystring (i.e. <a href="myform.asp?val1=redwidget">), which I think is fairly common practice. I don't know anything about DW MX but there must be some capability to get querystring info on the server side.

chowcat

2:11 pm on Sep 10, 2002 (gmt 0)



Ok, I'll give it a go, I didn't realise it was that straight forward. (famous last words)

threecrans

2:15 pm on Sep 10, 2002 (gmt 0)

10+ Year Member



I hope you understood that you have to retrieve the querystring on the server side and use it to create your form. For example, in ASP, if I linked to a site using

<a href="myform.asp?val=redwidget">

I would have to write code something like the following to extract the value and create my form.
<%
dim val
val = Request.QueryString("val") ' Contains "redwidget"
%>

<form name="form1" action="myhandler.asp">
<input type="text" value="<%=val%>" name="text1">
<input type="submit">
</form>

But, I've never used DW so I don't know what the equivalent would be. Also, it could be created to be much more functional. For example, in my case I pass a querystring value that I use to extract values from a database to initialize the form.

Sorry I was so unclear before.

chowcat

2:20 pm on Sep 10, 2002 (gmt 0)



Ok, my famous last words are now officially famous.

So, if I use a small piece of ASP to process the form, which I do, then it is in there that I need to add the bit above that you just posted.?

threecrans

2:47 pm on Sep 10, 2002 (gmt 0)

10+ Year Member



So, if I use a small piece of ASP to process the form, which I do, then it is in there that I need to add the bit above that you just posted.?

Cool. So you either code against IIS or Macromedia has some integrated support built into their server which allows ASP to run. So this proves my DW ignorance :)

Sounds like you should be able to mod the code snippet to meet your requirements.

chowcat

3:03 pm on Sep 10, 2002 (gmt 0)



...well I've given myself something to play about with for the next couple of hours no doubt. Thanks. :)

txbakers

3:21 pm on Sep 10, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure if this is what you are after, but in a list of names in a dropdown box, a user selects one and goes to that page. You want the drop down box to point to that name right?

I use a little javascript function for this which is very easy:

function setPart() {
for ( i=0; i<document.stuForm.vpart.options.length; i++) {
//alert( document.stuForm.vpart.options[i].value );if (document.stuForm.vpart.options[i].value == document.stuForm.part.value) {
//alert("Match!");[\1]
document.stuForm.vpart.selectedIndex = i;[\1]
}
}
}

There are hidden input fields which contain the page information.
At the bottom of the page I call the function.

chowcat

3:53 pm on Sep 10, 2002 (gmt 0)



..what I was actually looking at doing was making the name of the "widget" appear in a normal text field, without the text box, if that makes sense, the way it is currently set up is so that they choose from a drop down, which is what I wanted to loose.

I was looking at using one form and just having the name of the "widget" already displayed at the top of the form depending on what particular "widget" page they were referred from!

Filipe

9:49 pm on Sep 10, 2002 (gmt 0)

10+ Year Member



"normal text field" as opposed to a "text box". Do you just mean it will display the text and not be a form field at all? I would avoid using the word "Field" if this is what you mean.

chowcat

7:59 am on Sep 11, 2002 (gmt 0)



For example:::

Widget Type : Red Widget

Date of Delivery : TEXT FIELD

Email Address : TEXT FIELD

....etc

txbakers

11:37 am on Sep 11, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh, that's even easier.

Just write the text to the page like you would any other text. Just because it is embedded in a form doesn't mean you always have t use form elements.