473,402 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Inserting HTMLInput Element value

162 100+
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.

Expand|Select|Wrap|Line Numbers
  1. <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.
Sep 11 '08 #1
6 1260
Ferris
101 100+
Hi

The reason why you get "B" , not "Brazil" , is that "makeRequest" will be execute before the text field changed into "Brazil". So change your code into this:

Expand|Select|Wrap|Line Numbers
  1. <input type="text" name="country"
  2. onkeyup="ajax_showOptions(this,'get_country',event)" 
  3. onblur=" var _this = this; setTimeout( function(){ makeRequest('insert.php','?field_name=country&field_value='+_this.value); } , 300 );">
  4.  
the code will make "makeRequest" executed for 300 ms delay.

I didn't test my code up there. If the code is not working,post a reply to tell me. :)


Regards.
Sep 12 '08 #2
empiresolutions
162 100+
ferris - I have tried this solution all ready. doesn't work. The timeout only delays the inevitable. Thanks for the time in your suggestions though.

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.
Sep 12 '08 #3
Ferris
101 100+
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.

Brilliant. I think this is the best solution.
Sep 12 '08 #4
empiresolutions
162 100+
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?
Sep 17 '08 #5
acoder
16,027 Expert Mod 8TB
When does this hidden value get set?
Sep 18 '08 #6
Ferris
101 100+
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?

Hi,I test the code, *document.getElementById('country_hidden').value* will return a integer,which means country's ID.

what do you want to send to insert.php? Country's ID or Country's name?

Expand|Select|Wrap|Line Numbers
  1. insert.php?field_name=country&field_value=24
or

Expand|Select|Wrap|Line Numbers
  1. insert.php?field_name=country&field_value=Brazil
Sep 19 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: bill | last post by:
How can I insert a record with a null value in one of the fields? I need to use the update method from a data adapter. The data is in a XML file.
4
by: ~Gee | last post by:
Hi, When I try to compile the following program, I get the following error: $ g++ anotherTest.C anotherTest.C: In function `int main()': anotherTest.C:47: void value not ignored as it ought to...
2
by: Asad | last post by:
I have a form on a page that has several textareas, and textboxes inside a table (so the table containing the textboxes is also inside the FORM tag). I want to replace the textareas with simple...
10
by: Ryan Graham | last post by:
I totally bombed this question in an interview so I'm posting my answer here for comments and suggestions... perhaps (god help me) I'm just not that bright, but this works and seems to be fairly...
6
by: Newbie | last post by:
hi all, in a webform's codebehind, i have a variable (ie: nTotal). and in UI i have a hidden htmlinput (ie: fld1). Q: how to assign the value of nTotal to now i want to assign the value of...
11
by: Mark Rae | last post by:
Hi, Is there any way to modify the style of the button portion of an HtmlInput control? I have a CSS class which I use for all of the buttons to try to make them a little less ugly than the...
8
by: Stefan Mueller | last post by:
I'm really very confused. With the following code I can add rows/fields in frame 1 and 2. If I use IE, Mozilla or Opera the new rows/fields get added in ascending order. However, if I use Safari...
15
by: Jaraba | last post by:
I am working in a project that I need to parse an arrayt an select records based upon the values parsed. I used the functions developed by Knut Stolze in his article 'Parsing Strings'. I am...
1
by: madhuxml82 | last post by:
Dear Forum Members, I have generated an XML Schema and a Table of XMLType referencing the XML Schema. Now When I am Inserting the Data into the Table. I am getting the Error 0RA-30937: Error is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.