Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Inserting HTMLInput Element value
Old 09-11-2008, 04:00 PM Inserting HTMLInput Element value
Extreme Talker

Posts: 199
Trades: 0
I have a textfield that uses a dynamic dropdown select script to let me choose a country by a few letters. Example, keying "B" shows "Brazil, Bulgaria, Belarus... Once i choose a county another function fires to send the selected data via http_request to another page. Here's it in use.

Code:
<input type="text" name="country" onkeyup="ajax_showOptions(this,'get_country',event)" onblur="makeRequest('insert.php?field_name=country&field_value=',this.value)">
The problem is that the *this.value* in makeRequest() only sends the "B" or whatever chars where entered in the field. Now I understand that the dropdown script is filling the field in a different way than I would have keyed it but how im not sure. Looking at FireBug i think i see that my selection "Brazil" shows under *HTMLInputElement*. I guess my question is how do i get that value to show instead of *this.value* in makeRequest().

FYI, each script works fine when not working together on the same field.

Thanks much for the help.
empiresolutions is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-12-2008, 04:23 AM Re: Inserting HTMLInput Element value
Extreme Talker

Posts: 199
Trades: 0
thanks to BrianOConnell -

Solution - replace *this.value* with *document.getElementById('country_hidden').value*.

The country_hidden element was not in my initial post because i didn't think it was relevant.. bad me. It is shown in the original example linked in my post.
empiresolutions is offline
Reply With Quote
View Public Profile
 
Old 09-12-2008, 04:24 AM Re: Inserting HTMLInput Element value
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Use this.options[this.selectedIndex].value to get the value of the selected option from a select element.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-17-2008, 06:01 AM Re: Inserting HTMLInput Element value
Extreme Talker

Posts: 199
Trades: 0
chrishirst - im not using a regular select. its a dynamic suggest script. maybe the name i used confused you. thanks though fro trying.
empiresolutions is offline
Reply With Quote
View Public Profile
 
Old 09-17-2008, 06:02 AM Re: Inserting HTMLInput Element value
Extreme Talker

Posts: 199
Trades: 0
darn.. found a glitch. the *document.getElementById('country_hidden').value* will not set on the first call of makeRequest(). It will though set if i re-select the drop down value again. Any ideas on hoe to get it to set the first time?
empiresolutions is offline
Reply With Quote
View Public Profile
 
Old 09-17-2008, 08:18 AM Re: Inserting HTMLInput Element value
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Try the onchange event, as onblur will only trigger when the element loses focus
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Inserting HTMLInput Element value
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23065 seconds with 12 queries