3 Replies - 17652 Views - Last Post: 11 March 2007 - 10:05 AM Rate Topic: -----

#1 rpjd  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 88
  • Joined: 08-March 07

database query using html select option

Posted 09 March 2007 - 04:54 PM

I need to query a postgresql database using a value selected from an html select form.
I cannot find any site which discusses this
I am using the following code to capture the forms selected value

document.form.partname.option.selected

the select form name is partname.

Not sure if I am using the correct syntax.

RPJD :)

Is This A Good Question/Topic? 0
  • +

Replies To: database query using html select option

#2 snoj  Icon User is offline

  • Married Life
  • member icon

Reputation: 93
  • View blog
  • Posts: 3,583
  • Joined: 31-March 03

Re: database query using html select option

Posted 09 March 2007 - 05:36 PM

For starters, you can't query a database with HTML.

As for the javascript, you need to specify which form you wish to use from the page. (If there is only one form then document.forms[0].)

You may want to take a look at the documentation for the Mozilla DOM as it is very helpful and in many regards it's the same as what IE uses.
Was This Post Helpful? 0
  • +
  • -

#3 rpjd  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 88
  • Joined: 08-March 07

Re: database query using html select option

Posted 11 March 2007 - 08:27 AM

View Postrpjd, on 9 Mar, 2007 - 04:54 PM, said:

I need to query a postgresql database using a value selected from an html select form.
I cannot find any site which discusses this
I am using the following code to capture the forms selected value

document.form.partname.option.selected

the select form name is partname.

Not sure if I am using the correct syntax.

RPJD :)


My apologies, what meant to say, should have said was I am (hopefully) connecting to a Postgresql database using php embedded in a html file, using a selected form value as the basis of a select statements so
</php $a = pg_connect("select x from tablename where y = 'document.form.formname.option.selected';")
I am then trying to assign the value $a to a text field within the same form.
although document.forms[0] does looks much tidier I must admit!

When I assign the value to a text field say
<input name="x" value="<? php echo$a; ?>">
the php code is visible in the text field :)

RPJD
Was This Post Helpful? 0
  • +
  • -

#4 snoj  Icon User is offline

  • Married Life
  • member icon

Reputation: 93
  • View blog
  • Posts: 3,583
  • Joined: 31-March 03

Re: database query using html select option

Posted 11 March 2007 - 10:05 AM

That won't work because you're using Javascript within PHP. You'll need to send a new query/request to the server using some AJAXy type stuff or just have the whole thing reloaded when an option is selected.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1