Onchange event for readonly or disabled field?

P

pbd22

Hi.

Is this possible?

In my program, I have GMap logic that outputs location information to
a disabled input field (was previously a label). Then, when a
user clicks on a link (to start a new map), I want to save the
location
data to an array prior to server processing. So, onchange, save the
input field's value to array[last_click]. But, because this field is
hidden (or readonly) I am not sure how to go about this.

Help appreciated.
Thanks.
 
T

Thomas 'PointedEars' Lahn

pbd22 said:
Is this possible?

In my program, I have GMap logic that outputs location information to a
disabled input field (was previously a label). Then, when a user clicks
on a link (to start a new map), I want to save the location data to an
array prior to server processing. So, onchange, save the input field's
value to array[last_click]. But, because this field is hidden (or
readonly) I am not sure how to go about this.

Help appreciated.

Relevant source code or URL of a test case appreciated, as recommended by
the FAQ:

http://www.jibbering.com/faq/#FAQ2_3
http://www.jibbering.com/faq/faq_notes/clj_posts.html#ps1Quest


PointedEars
 
L

Lee

pbd22 said:
Hi.

Is this possible?

In my program, I have GMap logic that outputs location information to
a disabled input field (was previously a label). Then, when a
user clicks on a link (to start a new map), I want to save the
location
data to an array prior to server processing. So, onchange, save the
input field's value to array[last_click]. But, because this field is
hidden (or readonly) I am not sure how to go about this.

I don't see that you want to do anything onchange of the disabled
field. You seem to want to read it when the user clicks the link.


--
 
P

pbd22

pbd22 said:


Is this possible?
In my program, I have GMap logic that outputs location information to
a disabled input field (was previously a label). Then, when a
user clicks on a link (to start a new map), I want to save the
location
data to an array prior to server processing. So, onchange, save the
input field's value to array[last_click]. But, because this field is
hidden (or readonly) I am not sure how to go about this.

I don't see that you want to do anything onchange of the disabled
field. You seem to want to read it when the user clicks the link.

--

Yes, I think you are correct but I still seem to be getting in a bit
of a tail-spin. Per Thomas' suggestion, I have provided the core of my
code below.

The google maps javascript I have has a function, showPosition, that
gets called whenever the marker is moved and the coordinates
get written:

function showPosition(form, pos) {

var coords = document.getElementById('coords');
if (coords) coords.value = pos.toUrlValue();

}


I also have a file selector on the page. The user can select multiple
files for upload. The idea is that when a user clicks
on a file (in the queue) it activates the elements on the page
for associated input (such as Title). WHen a new file is clicked on,
the fields clear and allow for new information (or load the pre-
existing information from an array).

The logic works in all the fields (I removed all of them except the
Title input for clarity) except the file_location field due to its
disabled status. So, "onchange = function()" is not possible.

Lee - per your suggestion I have tried just leaving the raw code:

arrLocation[last_click] = file_location.value;

without the surrounding onchange logic. This produces odd results.
The array doesn't get populated until after several clicks, so, the
first attempts do not get recorded.

So, if anybody has an idea how I could successfully record the last
map value for a selected file and record it in the array
arrLocation[n] that would be very helpful.

Thank you!

function fileSelector( list_target, max ){

[SNIP]

/**
* Add a new file input element
**/

this.addfile = function( element ){

[SNIP]
};


/**
* Add a new row to the list of files
*/

this.addRow = function( element ){



// Title box
var arrTitle = new Array(max_count.length);
var title_box = document.getElementById('title');

// Marker Location
var file_location = document.getElementById('coords');
var arrLocation = new Array(max_count.length);

// Event handlers

var last_click;

new_link.onclick = function() {

title_box.value = "";

//file_location.value = ""; // REMOVE THIS

for(i=2;i<=max_count.length;i++) {


if(i == active) {

// Fill Pre-Existing Values

if(arrTitle)
title_box.value = arrTitle;

if(arrLocation)
file_location.value = arrLocation;

title_box.onchange = function (){
arrTitle[last_click] = title_box.value;
}


//file_location.onchange = function(){
arrLocation[last_click] = file_location.value;
//}

last_click = i;

}

}

}

};

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top