简体   繁体   English

重定向到具有相同形式的其他URL

[英]redirect to different URL with same form

i am new to PHP and trying to arrive with similar functionality given in URL . 我是PHP的新手,并尝试提供URL中提供的类似功能

i have a form with four select options, result will be retrived when last option selected. 我有一个带有四个选择选项的表单,选择最后一个选项时将检索结果。

my current code is : 我当前的代码是:

{
  $result = mysql_query($query,$con);

  if(!$result)    
    echo mysql_error();

  $option = "";

  while($row = mysql_fetch_assoc($result)) {
    $option .= '<option value = "'.str_replace(' ', '_', $row['bankname']).'">'.$row['bankname'].'</option>';
  }

  str_replace(' ', '_', $row['bankname'])  
?>

<form method = "POST" action = "">

<select name = "bank" onChange="document.location.href=bank[selectedIndex].value">
<?php echo $option; ?> 

</select>

</form>

}

Probably i am asking very high level question, but please help. 可能我在问一个非常高级的问题,但是请帮忙。

Regards, Anitha 问候,Anitha

您可以使用ajax进行首次发送,并且ajax成功后,您可以更改提交表单,再次返回true。

If I got the question right, you are not looking for loading options into select box, but trying to look for a solution where the last select box have values: 如果我的问题正确,那么您不是要在选择框中加载选项,而是要寻找最后一个选择框具有值的解决方案:

    <select id = 'finalSelect'>
        <option value='http://aaaa.com'>A<option>
        <option value='http://bbbb.com'>B<option>
        <option value='http://cccc.com'>C<option>
    </select>

and based on the user selection your page should redirect to aaaa.com, bbbb.com or cccc.com. 并且根据用户选择,您的页面应重定向到aaaa.com,bbbb.com或cccc.com。

If I am right about your requirement, all you have to do is: 如果我对您的要求是正确的,那么您要做的就是:

    <select id = 'finalSelect' ONCHANGE="location = this.options[this.selectedIndex].value;>
        <option value='http://aaaa.com'>A<option>
        <option value='http://bbbb.com'>B<option>
        <option value='http://cccc.com'>C<option>
    </select>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM