Solved

Need Help on html links...

Posted on 2001-06-25
33
147 Views
Last Modified: 2010-04-09
I have got a page with database fields on it asking questions such as firstname & surname.

The fields are named firstname/surname etc. I already have some information on people and would like theys fields to fill themselfs in so i would like to be able to do somthing like this.

www.internet.com/diretory/file.html?firstname=Paul.

then the firstname is filled when they get to the page.

Please help the ?firstname=Paul bit does not work so i would like to know how to work around this.
0
Comment
Question by:Duke01
  • 17
  • 14
  • +1
33 Comments
 
LVL 15

Accepted Solution

by:
a.marsh earned 300 total points
ID: 6223878
HTML will not provide this functionality for you.

You must be using some kind of scripting language on the server to pull data from the database - why not get that to do it?

If that isn't an option then it can be done using javascript, but I would recommend doing it using the server side script.

Here is an example of pulling data from the query string in javascript:

<html>
<head>
<script language="javascript">
<!--
var queryString = window.location.href.substring((window.location.href.indexOf('?') + 1));
function getValues(){
 var array1 = queryString.split('&'); // Each array element is in format "fieldname=value"
 for(var i = 0; i < array1.length; i++){
   var tempArray = array1[i].split('='); // Separate fieldname and value
   eval("document.forms[0]." + tempArray[0] + ".value = \"" + tempArray[1] + "\"");
 }
}
//-->
</script>
</head>
<body onLoad="getValues();">
<form method="get">
<input type="text" name="field1" value="">
<input type="text" name="field2" value="">
<input type="submit">
</form>
</body>
</html>

If you load the page, enter some values and then submit the form, you will say that page reloads itself and the values in the query string in the address bar are placed in the appropriate text box. :o)

Ant
0
 

Author Comment

by:Duke01
ID: 6223937
arse so its not possable at-all.

I tride you code out and it works but how come you cant flip it around and make it work the other way?
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6223943
What do you mean by "flip it around"?

:o)

Ant
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6223945
And you can do it on the server as I mentioned, you just cannot do it with just HTML.

:o)

Ant
0
 

Author Comment

by:Duke01
ID: 6223956
arse so its not possable at-all.

I tride you code out and it works but how come you cant flip it around and make it work the other way?
0
 

Author Comment

by:Duke01
ID: 6223960
i mean put the code in the add line and it puts it in the fields.  the one you gave me put the field info into the add line..  oh well.

are you sure its not possible..
0
 

Author Comment

by:Duke01
ID: 6224034
i mean put the code in the add line and it puts it in the fields.  the one you gave me put the field info into the add line..  oh well.

are you sure its not possible..
0
 

Author Comment

by:Duke01
ID: 6224045
ok situation is i have a oracle database called live with 2 tables cust and surv.  all the peoples info is in cust the new html page goes thu 3 java scripts and put the info into surv.

to be able to check the records and to get some more info from them i have put some fields in the new database that are the same as the old one.  but so people dont get pissed off with it i want the email_address and things to fill in auto.

how would i do it on the surver rembering that each person will need to see someing new...

???
0
 

Author Comment

by:Duke01
ID: 6224110
ok situation is i have a oracle database called live with 2 tables cust and surv.  all the peoples info is in cust the new html page goes thu 3 java scripts and put the info into surv.

to be able to check the records and to get some more info from them i have put some fields in the new database that are the same as the old one.  but so people dont get pissed off with it i want the email_address and things to fill in auto.

how would i do it on the surver rembering that each person will need to see someing new...

???
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6224120
Click on the "Reload Question" link in the top right hand corner of the page rather than using "Refresh" - that way you won't keep posting the same comment! :o)

Ant
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6224121
Okay, how do you know who is actually looking at the page in question? Do they log in first or something?

:o)

Ant
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 6224179
:-) @ Ant
0
 

Author Comment

by:Duke01
ID: 6224191
at the moment i do not have a login page setup but when i send out the email i can automaticaly fill in there details as the mail system has a link into the cust database.

i was hoping to avoid a login page...
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6224198
Okay, I see what you mean.

I personally would use a server based script - what database are you using on the server and what server-side scripting do you have available to you?

:o)

Ant
0
 

Author Comment

by:Duke01
ID: 6224218
oracle 8.15 and i use java1.2 with JavaWebserver2.0..
0
 

Author Comment

by:Duke01
ID: 6224253
on a unix box.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 15

Expert Comment

by:a.marsh
ID: 6224285
I assume that each person has their own unique id in the database?

Hence I would suggest the following:

1 - Write a java servlet that will accept a unqiue user id and hence can extract the appropriate data from the database. The servlet will then generate the HTML page and plug in the data it has got. So as an example, one of the lines of the servlet will be similar to:

response.println("<input type=\"text\" name=\"firstname\" value=\"" + dataarray["firstname"] + "\">");

2 - In the email get it to point to the user's unqiue id rather than contain all of their details (one big advantage is that if their details change in the database, the email is not going to contain old data) e.g.

http://www.yourdomain.com/servlets/displayData?id=99

Voila! The relevant data is displayed in the HTML form.

Now the only issue now is how well you know how to write Java servlets!

Ant
0
 

Author Comment

by:Duke01
ID: 6224298
Im not big on java i only just got the page to put the data into the database after about 3 months of books and help...

i have increased the points to this question if you could help me with the java side let me know and i will give you my email address.

if not i will still give you the points for the help you have given..

but i would like some help with the java if you can please...
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6224317
Sure, no problem.

You've actually already done the biggest thing - connecting to the database!

What would be useful is if you could send me the java source for the servlet that you have written already - that will give me the information I need to put the core of the new servlet together for you.

What would be even better is if you had a go and then come back with any problems.

It is up to you. If you want to send me the source then you can email me at:

ant_marsh@yahoo.co.uk

Any other correspondence should take place on this question so that a complete "conversation" is kept for others to make use of in the future.

In terms of the source code you send me, I shall NOT put any of it on this question that is sensitive - e.g. servernames, usernames and passwords etc.

:o)

Ant
0
 

Author Comment

by:Duke01
ID: 6224391
i have just sent you an email with some more info and the survlets...

thanks

:o)
0
 

Author Comment

by:Duke01
ID: 6227085
any luck so far mate?
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6227100
Hi Duke01....I had a quick look yesterday after receiving your email - I'm pretty busy at the moment with a major project and I'm helping out on EE whenever I can - it doesn't also help that I haven't touched Java in about a year!

I shall get cracking on something as quick as I can....however I would suggest that you give it a ago whilst you are waiting.....as I mentioned previously you have done most of the hard work already in terms of getting a Java servlet to connect to the database.

Give it a go (if you can) and any issues simply post the code here - it will be easier for me to help you with code you've got partially working than me trying to put something together for scratch.

As much as I love helping people on here, I do have to do a good job at work in order to keep my monthly salary coming in!!

:o)

Ant
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6227105
Basically the structure of the Java servlet will be like this (as I see it):

1 - Get the id passed to the servlet

2 - Connect to the database

3 - Query the database, essentially asking for the record where the id is equal to the id passed to the servlet

4 - if no record returned then display error page for user

5 - else create HTML output, using lines similar to what I gave earlier e.g.

response.println("<input type=\"text\" name=\"firstname\" value=\"" + dataarray["firstname"] + "\">");

And that's it!

:o)

Ant
0
 

Author Comment

by:Duke01
ID: 6227111
No worrys i have started on the codeing i was just wondering if you had got a chance yet.

sorry if i have been bothering you i understand the work side of things no need to explain i was just catching up.

:o)

Duke
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6227127
I understand that you want to get a solution as quickly as possible - and I'll help all I can - we're getting there! :o)

Get as far as you can with the code you are working on, and then stop back here if you get stumped.

Ant
0
 

Expert Comment

by:jgeoff
ID: 6235322

If you have PHP available to you, this might be easier... just a thought.

~JG

0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6235584
I'm inclined to agree with you jgeoff - and I am currently using PHP which means I could probably help you a lot quicker Duke01!

However, you are already using the Java servlets... so I would probably stick with them.

Ant
0
 

Author Comment

by:Duke01
ID: 6235635
i dont have php so we have to stick java servlets,

Regards - Duke ;o)
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6235650
How are you getting on Duke01?

Anything you want me to help you with yet?

:o)

Ant
0
 

Author Comment

by:Duke01
ID: 6251925
ohh my god it worked first time mate thanks for all your help. i have acceped your answer and you should have the points now

(!
  _) )
(!
0
 

Author Comment

by:Duke01
ID: 6251928
Thanks again for all your help...
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6251954
Brilliant!

Glad I could help. :o)

Thanks for the A grade.

Ant
0
 

Author Comment

by:Duke01
ID: 6251971
no worrys mate.. thanks again..

p.s. sad old me has a new question up about a questbook if you feel like haveing a look...
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now