javascript - Post variable on hyperlink -


i have drop down list in php page hyperlinked different pages contained on different servers; html, asp.net pages etc.

the url of these pages not contain same domain name drop down list. therefore, in order prevent user directly entering url in address bar, post variable when user clicks item in list.

this variable sent along hyperlinked url. asp.net page check whether variable received along request, if yes page load otherwise asp.net page redirect user home page.

my question: process of posting variable? in hyperlink variable need included. totally lost.

edit: tried post through form.submit

<li><form id="sampleform" name="sampleform" method="post"> <input type="hidden" name="total" id="total" value=""> <a onclick="setvalue();">elmstest</a> </form></li>  <script type="text/javascript"> function setvalue(){     document.sampleform.total.value = 100;     document.forms["sampleform"].submit(); } </script> 

i dont know how proceed here.

try using post action. virtue of having `method="post" on tag.

`<form id="sampleform" name="sampleform" method="post">` 

because have no action="script.php" send inputs script generated page , run again. assuming called script.php...

in php code of script.php data delivered in $_post array.

<?php      if ( isset($_post['total'] && $_post['total'] == 1 ) {         // have foo variable value of one. it.     } 

if want use action or add variables hyperlink as:

www.domain.net/script.php?foo=1&bar=2 

the ? starts list of variables, querystring , each variable seperated & if want pass more one.

and of course variables passed in $_get array php code.

<?php      if ( isset($_get['foo'] && $_get['foo'] == 1 ) {         // have foo variable value of one. it.     }      if ( isset($_get['bar'] && $_get['bar'] == 2 ) {         // have bar variable value of two. it.     } 

Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -