Click to See Complete Forum and Search --> : Auto Filled in Fields of a form?


JonathanDoe
02-05-2003, 04:30 PM
I am creating a form for users to register for seminars. I have a field which they can write what seminar they would like to register for, but on a page which lists the available seminars, they can click on a "resgiter now" link, which sends them to the page with the form.

What I was wondering is if I can have the seminar field already filled in for them depending on which link they clicked on. So it must recognize which link was clicked. I was trying to pass parameters in the URL by adding the ?parameter_name after the url. But I wasnt sure how to set the value of the text field so that it displays the seminar name?

So what I want is for them to enter their email, phone number and name, but the seminar field is already filled in upon arriving at the page.

Any ideas on how this can be done?
It would be much appreciated!
ThanX!!

JonathanDoe
02-06-2003, 08:28 AM
Thanks for the link, I was wondering though am I able to take those variables passed in and put them in the value="..." part of the input tag....so that the field is filled with that parameter upon entering that page. To my knowledge I cant extract those variables out in javascript and be able to use them in HTML like in the form?

Thats where I'm having trouble....maybe I'm just seeing something wrong?

Thanks again,
Chris

sdonato
02-06-2003, 10:50 AM
are you using straight HTML... easy to do with ASP or PHP.

never actually needed to do it outside of those lanuguages

usaully it is just a <% request.string("passedfield")%> in asp

sorry if i am no help

-sdonato

sdonato
02-07-2003, 06:43 AM
i just usually use request("") it is easier to remeber

i forgot about the QueryString part.

thanks for reminding me ;)

-sdonato

JonathanDoe
02-07-2003, 08:42 AM
Thanx Dave, thats actually how I did end up setting the field like that, but I pass what I want in the field after the url like
?Begin_With_the_End_in_Mind and on this new pop up window which is a registration for, that seminar field is filled with that.

I used

var str = location.search.substring(1);
document.register.course.value = str;

in javascript to get the parameter fromthe url, however my problem is that the field still contains the underscores, not that I'm too bother by that, but I would like to remove them, and I tried to run through the string searching for eah '_' and replace it by a ' ' space, but it doesnt seem to work?

Maybe the syntax is wrong,

for(i=1;<=str.length;i++)
{
if(str[i]=='_')
str[i]=' ';
}
and then I have the line with document.register.course.value =str;

so I'm not sure what I'm doing wrong

Advice would be appreciate if you have any ideas....

Thanx again you've been a big help

JonathanDoe
02-10-2003, 08:24 AM
Great! Thanx dave, you've been a huge help!

JonathanDoe
02-10-2003, 08:46 AM
Small problem again, for some reason it onl removes the first underscore. If I call this line

str = str.replace(/_+/," ");

every time it will replace one more undersocre in the line and then finally write this to put it in the field

document.register.course.value = str;

I was wondering how this can be resolved, whether it needs a loop to go through and call the replace function multiple times or if there is another way around it.

Thanx again

JonathanDoe
02-11-2003, 08:29 AM
Thanx again Dave, you're a big help. I ended up getting it working with a loop, but this is much more efficient. Thanx.