Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

Javascript reading textbox


  • Please log in to reply

#1
Metallica

Metallica

    Spyware Veteran

  • GeekU Moderator
  • 31,673 posts
This is hopefully very easy for a more experienced javascripter. I just can't figure out why it's not working.

This php script http://www.pieter-ar...h...4&havens=15
produces 4 distances in the textboxes below the maps.
What I want is to give the user a short chance to verify if all the data are there before he clicks "Versturen".
That activates a new script which works fine once it gets the correct data, but I didn't copy it to my server.

The problem is I can't figure out how to read the data in the textboxes.

I have tried document.getElementById() which passes a mix of null and [object]
If it is any help, the [object] is always the last one I calculate.
So, my suspicion is that the id is replaced by the last one for all the distances.

My question: is there a way to read the data from the textareas with another method that is not dependant on the way the data were put there.

Sorry if this is all very confusing, but confused is what I am right now. :)


PS The textboxes do not show up in Opera, so they may not be rendered properly in other browsers either. For the purpose of the script this is irrelevant, so I couldn't care less. Just wanted to let you know since most of you use more advanced browsers.
  • 0

Advertisements


#2
Ax238

Ax238

    Tech Staff

  • Technician
  • 1,323 posts
Hi Metallica,

Looks like what is happening is you have multiple declarations of the customPanel (and detail) function in the source. You then set a timeout for each one of these functions to run. I'm guessing they all run four times for each div, but the last one (function customPanel(frame4,mapname,dirn4,div) for me) gets final say on what the innerHTML value ('<input type=text id=antw size=6 value=' + Math.floor(kms4/1000) + '>' for me) is for the div. It is important to note that although the id is the same for each of the text boxes, each one has its own value (156, 208, 191, 176). I'm guessing the javascript is generated from your php script. Making the function name different for each div would be the easy fix, making the [one] function work for each div would be the optimal fix.

Regards,

Ax
  • 0

#3
Metallica

Metallica

    Spyware Veteran

  • Topic Starter
  • GeekU Moderator
  • 31,673 posts
Hi Ax,

Your advise is very welcome as always.
You are certainly right about the php script generating the javascript for each instance that I need to run.
It is also correct that the last one gets the value of the first ones (depending on how the time-out runs out).
I just figured if I could "read" the values of the text boxes independent of their id (or name) I got what I wanted.

But I'm not sure if I get what you think needs changing.
(function customPanel(frame4,mapname,dirn4,div))
Replace the part in bold by div1 etc, so they end up in the same div as the labels? I have tried this and they all ended up in div4 :)
  • 0

#4
Metallica

Metallica

    Spyware Veteran

  • Topic Starter
  • GeekU Moderator
  • 31,673 posts
I made some changes to steer around the timeout issues:

http://www.pieter-ar...t/onebyone.html

You have to click the buttons labelled "opslaan" once the route is ready for each map.
So they can't overlap.
I still can't get the data submitted. :)
  • 0

#5
Metallica

Metallica

    Spyware Veteran

  • Topic Starter
  • GeekU Moderator
  • 31,673 posts
I found out what you meant Ax.

By numbering the custompanel functions I solved the problem.
customPanel4(frame4,mapname,dirn4,div))
  • 0

#6
Ax238

Ax238

    Tech Staff

  • Technician
  • 1,323 posts
Sorry I couldn't get back to you earlier Metallica, I've been a bit busy lately and haven't been online as much. Your last post captures my intended explanation of the issue and resolution. I'm glad you got things sorted out.

Ax
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP