Jump to content

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


rajmohan

Recommended Posts

JavaScript event listener

// mozilla

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

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

[url=http://developer.mozilla.org/en/docs/DOM:element.addEventListener]http://developer.mozilla.org/en/docs/DOM:element.addEventListener[/url]

me!
Link to comment
Share on other sites

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


Link to comment
Share on other sites

[quote author=rajmohan link=topic=109403.msg440866#msg440866 date=1159190438]
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
[/quote]

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.
Link to comment
Share on other sites

AJAX is not too hard, requires some javascript and a backend query script.
Move to this forum section -> http://www.phpfreaks.com/forums/index.php/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.
Link to comment
Share on other sites

[quote author=businessman332211 link=topic=109403.msg441687#msg441687 date=1159280718]
onfucus, onblur then all you have to do is click in the field to get the value.
[/quote]

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... ???
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.