Jump to content


Photo

i want to get value from textfield without clicking button or link???? (HELP ME)


  • Please log in to reply
16 replies to this topic

#1 rajmohan

rajmohan
  • Members
  • PipPipPip
  • Advanced Member
  • 169 posts

Posted 25 September 2006 - 01:00 PM

I want to get the value from one text field without clicking the button or link from it

whether it is possible or not ??

Help me i dont know but it is required now for my project.

#2 printf

printf
  • Staff Alumni
  • Advanced Member
  • 889 posts

Posted 25 September 2006 - 01:13 PM

JavaScript event listener

// mozilla

el.addEventListener("event_to_monitor", function_to_fire_when_event_is_triggered, false);

event_to_monitor => (ie: keyup, onmouseover, ...)

http://developer.moz...ddEventListener

me!

#3 SharkBait

SharkBait
  • Members
  • PipPipPip
  • Advanced Member
  • 845 posts
  • LocationMetro Vancouver, BC

Posted 25 September 2006 - 01:14 PM

<?php
if(file_exists('path/to/file') ){
  fopen('path/to/file', filesize('path/to/file');
  $file = fread('path/to/file');
} else {
  echo "Cannot locate file.";
}
?>

Just put something like that in the beginning of the script your running?

#4 rajmohan

rajmohan
  • Members
  • PipPipPip
  • Advanced Member
  • 169 posts

Posted 25 September 2006 - 01:20 PM

No guys,

I am having a value in text field which is from javascript

example

var a_value = document.form1.ac.value;  // i pass value
var service_value = document.form1.service.value; // this also i am passing
document.form1.searchval.value = amc_value+','+service_value;

here i text field serchval got value now, i  should be take this value to my query without clicking the button or link




#5 SharkBait

SharkBait
  • Members
  • PipPipPip
  • Advanced Member
  • 845 posts
  • LocationMetro Vancouver, BC

Posted 25 September 2006 - 01:43 PM

Yea I completely read your post wrong sorry.

As for what you're trying to do I'm unsure how to go about it.

#6 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 25 September 2006 - 01:46 PM

No guys,

I am having a value in text field which is from javascript

example

var a_value = document.form1.ac.value;  // i pass value
var service_value = document.form1.service.value; // this also i am passing
document.form1.searchval.value = amc_value+','+service_value;

here i text field serchval got value now, i  should be take this value to my query without clicking the button or link


so... how is your form being submitted? you've got to have some sort of trigger event signaling your value to be added to your query. at the very least, you could set a timer to trigger every few seconds and grab the value, but that's not very efficient at all. if you're simply wanting to do it when the form is submitted, run your function during the "onsubmit" attribute of the form itself.
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#7 mewhocorrupts

mewhocorrupts
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts
  • LocationParker, CO

Posted 25 September 2006 - 03:14 PM

I think a JS timer would fix your problem.

<code>
timerID = 0;
timerID = setTimeout("UpdateTimerFunc()", 1000);

function UpdateTimerFunc()
{
    // Do whatever you need to do here.
}
</code>

It's the closes you'll get to actively monitoring a form field, as far as I know.
-mewhocorrupts

#8 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 25 September 2006 - 04:22 PM

i assume you are typing in a textfield and want it to query db once you have finished typing ? If so you should head over to the ajax forum with the attribute onchange=" " in your mind.

#9 rajmohan

rajmohan
  • Members
  • PipPipPip
  • Advanced Member
  • 169 posts

Posted 26 September 2006 - 03:50 AM

yes you are correct i want after getting the value in textfield it should be taken to my query execution??

This is what i needed it will be very helpful.

You told that ajax will be helpful but i dont have any idea about that one please is there any option




#10 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 26 September 2006 - 04:51 AM

AJAX is not too hard, requires some javascript and a backend query script.
Move to this forum section -> http://www.phpfreaks...board,51.0.html <- and ask the spesific question and i'm sure someone will show you an example and help you on the way.

#11 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 26 September 2006 - 10:20 AM

if you're running the query after every keystroke, instead of using onchange for a text field or textarea, you'll be better off using the onkeyup.
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#12 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 26 September 2006 - 02:25 PM

onfucus, onblur then all you have to do is click in the field to get the value.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#13 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 26 September 2006 - 02:28 PM

onfucus, onblur then all you have to do is click in the field to get the value.


how will that help? if you do an onfocus, you only get the value when you initially focus on the field which will be empty when you start. then, onblur, you'll have to focus away from the field, and if you're doing that, you might as well have a button or link to grab it anyway... ???
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#14 rajmohan

rajmohan
  • Members
  • PipPipPip
  • Advanced Member
  • 169 posts

Posted 27 September 2006 - 07:01 AM

i am asking without clicking the button are link (reason the page should not refresh)
i want ot get the value from the textfield. after receiving the values from javascript

#15 steveclondon

steveclondon
  • Members
  • PipPipPip
  • Advanced Member
  • 161 posts

Posted 27 September 2006 - 07:08 AM

I would have thought that with both onkeyup and onchange that every time the user types another letter it will query the database using ajax. I think it will be a hard thing to do without making the server do extra work, unless the user is typing in something that is the same length then you could check if after the user gets above that lenght.

If you think about it how will the form know when the user is getting to the end of what they are typing it will have to enter in the database every time they press a key. If you use the onblur method the user will still have to click else where on the form or press the tab. I think what you are trying to do isn't really possible. I would like to hear if you do manage to do it and how you have gone about it.

Good luck

#16 steveclondon

steveclondon
  • Members
  • PipPipPip
  • Advanced Member
  • 161 posts

Posted 27 September 2006 - 07:11 AM

sorry misread the first post. Thought you wanted to put it into a database. If you are only getting the value out ignore what I have said above. Perhaps you can put it to a $_SESSION value. Rewriting this everytime would be as bad as the database thing above, (don't know where I got the idea you wanted to do that).

Anyway you still need Ajax

#17 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 27 September 2006 - 08:51 AM

onchange responds only if the field value is changed and at the time you take the focus away from the field again, not while typing.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users