Sunday 15 March 2015

javascript - hidden INPUT value not available in $_POST -



javascript - hidden INPUT value not available in $_POST -

i have form utilize javascript set value of hidden input field text of option selected. $_post captures value of option not value of hidden input. hidden input beingness used pass option text available in $_post array.

this section of javascript used value , text of selected option

var sele = document.getelementbyid('building_type'); var seleval = sele.options[sele.selectedindex].value; var seletxt = sele.options[sele.selectedindex].text;

this set value of input field id of "other_hidden_text" in same javascript.

document.getelementbyid("other_hidden_text").value = seletxt;

my problem $_post['other_hidden_text'] empty. ideas why?

seems hidden input element not part of form element. in html if want utilize input elements, need include them in form, , specify submit info , utilize method (post or get) in attributes of form.

<form action="server_side_code.php" method="post"> <input type="text" name="value1" /> <input type="hidden" name="value2" /> <!-- ok --> <input type="submit" /> </form> <input type="hidden" name="value3" /> <!-- not sent anywhere -->

using proper tools can check info browser send server side code (for illustration php file searching values in $_post). example:

in firefox open tools > web developer > network (or press ctr + shift + q) in chrome open more tools > developer tools (or press ctrl + shift + i) , select network tab.

(other browsers might provide such tools, don't have them installed introduce how open developer tools).

then after submitting form, new line in list of network calls appear. click on , see parameters sent server side code. check if hidden field value there.

if see hidden field value in there, problem javascript not updating value of hidden input. maybe not beingness triggered.

javascript php html post

No comments:

Post a Comment