Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Text within Textarea using OnChange event in Select Box 1

Status
Not open for further replies.

dtrahokie

Programmer
May 10, 2004
25
US
I am pulling information in a select box from an Oracle database. When a user clicks on a value in the select box I would like to update the values in the textareas with the values in the oracle database connected to the entry in the select box.

Is this possible using javascript? I can't seem to figure out how to connect back to the Oracle database using javascript. I tried writing a regular ASP function, but realized that ASP is server side, and that probably wouldn't work.

How should I go about doing this? Is this even possible? I'm sure I've seen it on other sites.

Thanks much in advance!
 
it is possible,

in ur dropdown write a Javascript code that will resubmit the form to itself.

at the top of the page read the dropdown value, first time the page loads the value will be empty, but from the next time when it is resubmitted by javascript u must be able to read the dropdown's value.

once u got it u have to use ASP to read ur value from ur database...

Known is handfull, Unknown is worldfull
 
Hi

There are two approaches to solving this the first is how vbkris suggested, the second is to do this client side, it requires a little more javascript but is good as it is only one trip to the server.

The first part is building an array to populate the original drop down and then to match to the values for the text area.

Javascript.com has a linked-listbox script that you just need to mix with your ASP/Data.

Hope this helps

Thanks

Glen
 
Thanks Glenn and vbKris...

vbkis, I have a simple javascript function that has this one statement (gsql is my form name):
document.gsql.submit();

I'm getting an error that says:
Microsoft JScript runtime error: Object doesn't support this property or method

Is this anything that you could help me with?

THanks again!
 
Okay, I fixed the Javascript error thanks to some great folks in the Javascript form, but now it is not submiting the form to itself, but submitting it like normal to another ASP page.

Can I nest a form inside the gsql form and just resubmit that?
 
You can try:
document.form[0] if this is either the first or only form on the page, if not then just ammend the form[XX] to the number of the form. Count the forms on the page from the top down.

Which event handler are you using? eg. OnClick, OnPress etc

Thanks

Glen
 
I'm using the onchange event. Javascript is working well, but form is not submiting to itself - it's submiting to another ASP page (which is what i would like it to do eventually, but not before information from the database can be loaded onto the page and then edited).
 
Right I think i see what your trying to achieve.

Code:
<%
' Set dynamic submit location
Dim page

'hold the number of submissions
Session("subcount") = session("subcount")+1

Page = "samepage.asp"
submitcount = Request.Form("submitcount")
if session("submitcount") >= 2 then page = "nextpage.asp"
else
Page = "samepage.asp"
end if

%>

Now just place a hidden field in the form called submitcount with a value of 1

Code:
<input name="submitcount" type="hidden" value="1">

and in your form change the action to

Code:
<form name="name" method ="post" action=<%=page%>>
</form>

I hope this helps

thanks

Glen
 
Glenn: You're a genius! Thanks so much!

-Matt
 
Your welcome.

Will try and name everything consistantly next time though :p

Glen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top