rajmohan Posted September 25, 2006 Share Posted September 25, 2006 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. Quote Link to comment Share on other sites More sharing options...
printf Posted September 25, 2006 Share Posted September 25, 2006 JavaScript event listener// mozillael.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! Quote Link to comment Share on other sites More sharing options...
SharkBait Posted September 25, 2006 Share Posted September 25, 2006 [code]<?phpif(file_exists('path/to/file') ){ fopen('path/to/file', filesize('path/to/file'); $file = fread('path/to/file');} else { echo "Cannot locate file.";}?>[/code]Just put something like that in the beginning of the script your running? Quote Link to comment Share on other sites More sharing options...
rajmohan Posted September 25, 2006 Author Share Posted September 25, 2006 No guys,I am having a value in text field which is from javascriptexamplevar a_value = document.form1.ac.value; // i pass valuevar 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 Link to comment Share on other sites More sharing options...
SharkBait Posted September 25, 2006 Share Posted September 25, 2006 Yea I completely read your post wrong sorry.As for what you're trying to do I'm unsure how to go about it. Quote Link to comment Share on other sites More sharing options...
obsidian Posted September 25, 2006 Share Posted September 25, 2006 [quote author=rajmohan link=topic=109403.msg440866#msg440866 date=1159190438]No guys,I am having a value in text field which is from javascriptexamplevar a_value = document.form1.ac.value; // i pass valuevar 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. Quote Link to comment Share on other sites More sharing options...
mewhocorrupts Posted September 25, 2006 Share Posted September 25, 2006 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. Quote Link to comment Share on other sites More sharing options...
alpine Posted September 25, 2006 Share Posted September 25, 2006 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. Quote Link to comment Share on other sites More sharing options...
rajmohan Posted September 26, 2006 Author Share Posted September 26, 2006 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 Quote Link to comment Share on other sites More sharing options...
alpine Posted September 26, 2006 Share Posted September 26, 2006 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. Quote Link to comment Share on other sites More sharing options...
obsidian Posted September 26, 2006 Share Posted September 26, 2006 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. Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted September 26, 2006 Share Posted September 26, 2006 onfucus, onblur then all you have to do is click in the field to get the value. Quote Link to comment Share on other sites More sharing options...
obsidian Posted September 26, 2006 Share Posted September 26, 2006 [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... ??? Quote Link to comment Share on other sites More sharing options...
rajmohan Posted September 27, 2006 Author Share Posted September 27, 2006 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 Quote Link to comment Share on other sites More sharing options...
steveclondon Posted September 27, 2006 Share Posted September 27, 2006 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 Quote Link to comment Share on other sites More sharing options...
steveclondon Posted September 27, 2006 Share Posted September 27, 2006 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 Quote Link to comment Share on other sites More sharing options...
alpine Posted September 27, 2006 Share Posted September 27, 2006 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.