[PHP] php / JS / DOM question
I know that this is more of a Javascript / DOM question but I cannot for the life of me figure this out: I have this form: form name=query_form input type=text name=q/input input type=button onclick=drawImg('A',document.forms ['query_form'].elements['q']); value=Search/input /form When the user clicks on the button, I want the text that is in input elment 'q' to be sent to the Javascript function drawImg but when I debug it via alerts, it appears to be NULL. Looking at the examples online, I feel like this should work. Does anybody know why this might not be working correctly? -jonathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] php / JS / DOM question
Try: input type=text name=q id=q/input input type=button onclick=drawImg('A',document.getElementById('q').value); value=Search/input I didn't test this, but I think it'll work... -Original Message- From: jonathan [mailto:[EMAIL PROTECTED] Sent: Thursday, December 29, 2005 1:45 PM To: php-general@lists.php.net Subject: [PHP] php / JS / DOM question I know that this is more of a Javascript / DOM question but I cannot for the life of me figure this out: I have this form: form name=query_form input type=text name=q/input input type=button onclick=drawImg('A',document.forms ['query_form'].elements['q']); value=Search/input /form When the user clicks on the button, I want the text that is in input elment 'q' to be sent to the Javascript function drawImg but when I debug it via alerts, it appears to be NULL. Looking at the examples online, I feel like this should work. Does anybody know why this might not be working correctly? -jonathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php / JS / DOM question
Add the value property: document.forms['query_form'].elements['q'] .value. Kirk jonathan [EMAIL PROTECTED] wrote on 12/29/2005 02:45:23 PM: form name=query_form input type=text name=q/input input type=button onclick=drawImg('A',document.forms ['query_form'].elements['q']); value=Search/input /form When the user clicks on the button, I want the text that is in input elment 'q' to be sent to the Javascript function drawImg but when I debug it via alerts, it appears to be NULL. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php / JS / DOM question
thanks so much. i didn't realize but I did strip out all the php. My bad. -jonathan On Dec 29, 2005, at 1:48 PM, Dan Uyemura wrote: Try: input type=text name=q id=q/input input type=button onclick=drawImg('A',document.getElementById('q').value); value=Search/input I didn't test this, but I think it'll work... -Original Message- From: jonathan [mailto:[EMAIL PROTECTED] Sent: Thursday, December 29, 2005 1:45 PM To: php-general@lists.php.net Subject: [PHP] php / JS / DOM question I know that this is more of a Javascript / DOM question but I cannot for the life of me figure this out: I have this form: form name=query_form input type=text name=q/input input type=button onclick=drawImg('A',document.forms ['query_form'].elements['q']); value=Search/input /form When the user clicks on the button, I want the text that is in input elment 'q' to be sent to the Javascript function drawImg but when I debug it via alerts, it appears to be NULL. Looking at the examples online, I feel like this should work. Does anybody know why this might not be working correctly? -jonathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php / JS / DOM question
which is not part of the standards. It's accepted by most browsers because a lot of sites use it (due to the fact that IE is so popular), but it's *NOT* standard. So, don't do it! Dan showed the correct way. - tul [EMAIL PROTECTED] wrote: Add the value property: document.forms['query_form'].elements['q'] .value. Kirk jonathan [EMAIL PROTECTED] wrote on 12/29/2005 02:45:23 PM: form name=query_form input type=text name=q/input input type=button onclick=drawImg('A',document.forms ['query_form'].elements['q']); value=Search/input /form When the user clicks on the button, I want the text that is in input elment 'q' to be sent to the Javascript function drawImg but when I debug it via alerts, it appears to be NULL. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php