sayedsohail Posted June 27, 2007 Share Posted June 27, 2007 Hi everyone, I am trying to read some values from the page calling this function and pass this values from the input fields to the ajax function. Please its giving me erro's i need some urgent help please. Here is the code: <input type=hidden value="1" id='field_1text> <input type=text id='field_2text' onclick="javascript: checkmake('field_1text','field_2text')"> function checkmake(check_div1, check_div2) { if(check_div1 || check_div2) { var check_value1 = document.getElementById(check_div1).value; var check_value2 = document.getElementById(check_div2).value; MyAjaxRequest("displaymodels","requestmodel.php?amake=$check_value1&amodel=$check_value2"); } else { var check_value1 = ''; var check_Value2 = ''; alert("Please select the make first"); } } This showing me $check_value1 variable in my php file it's not passing the value of check_value1 or check_value2, please help. Link to comment https://forums.phpfreaks.com/topic/57388-getelementbyid-not-working-please-urgent-help-required/ Share on other sites More sharing options...
RichardRotterdam Posted June 27, 2007 Share Posted June 27, 2007 I think I see the problem check the following line MyAjaxRequest("displaymodels","requestmodel.php?amake=$check_value1&amodel=$check_value2"); if I am right $check_value1 $check_value2 are your php variables but your passing it as if they are javascript variables you need to convert this variable to javascript variable first try this: //pass php values to javascript var checkValue1="<?php echo($check_value1);?>"; var checkValue2="<?php echo($check_value2);?>"; //ajax request correction MyAjaxRequest("displaymodels","requestmodel.php?amake="+checkValue1+"&amodel="+checkValue1); oh one thing else i see you have both $check_value1 and check_value1 looks a bit confusing and in the following line var check_value1 = document.getElementById(check_div1).value; are you trying to get a value out of a div tag? Don't think div tags are suppose to have the "value" attribute they do have innerHTML so that would look like var check_value1 = document.getElementById(check_div1).innerHTML; Link to comment https://forums.phpfreaks.com/topic/57388-getelementbyid-not-working-please-urgent-help-required/#findComment-283953 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.