2012-07-10 42 views
0

我在PHP + HTML工作需要下拉式选单,选择价值

我有像这样定义的操作形式:

1]形式行动=“的index.php ?选项= com_advertisment &任务= keysearch & ITEMID = 2 & CATID = this.options [this.selectedIndex]。价值”

但下拉的设定值时,我提交表单未在查询字符串所示。

这意味着this.options[this.selectedIndex].value不是由value取代,但谈到,因为它是在查询字符串是这样的:

http://mydemoserver.com/index.php?option=com_advertisment &任务= keysearch & ITEMID = 2 & catid = this.options [this.selectedIndex] .value

如果有人知道解决方案,请帮助我。

谢谢

+0

你应该首先接受一些你的问题的答案 – Bergi 2012-07-10 07:32:16

+0

你可能混合了javascript和HTML,但没有任何源代码很难说。请发布一个示例(jsfiddle),演示您正在尝试执行的操作。 – Martijn 2012-07-10 07:36:55

+0

@Martijn是的,我会的 – banjali 2012-07-10 07:38:41

回答

0

它看起来像你试图混淆你的HTML和JS不正确。

如果您有<form>标签,只需将标签中的所有字段放入标签即可。

如果您希望前三个查询参数对是静态的,您可以将它们写入隐藏的<input>标签中。

例如:

<form action = "index.php" method = "GET"> 

<input type = "hidden" name = "option" value = "com_advertisment" /> 
<input type = "hidden" name = "task" value = "keysearch" /> 
<input type = "hidden" name = "Itemid" value = "2" /> 

<select name = "catid"> 
    <option value = "1">Some option</option> 
    <option value = "2">Another option</option> 
</select> 

<input type = "submit" /> 

</form> 
0

确保你给name属性为您的下拉/选择框。

eg. <select name="foobar"><option value='first'>First</option></select>

,改变你的<form>index.phpmethod='get'

这样的action属性一旦你提交表单,所有数据将被发送到你的PHP页面(的index.php在这种情况下, )通过get方法,你可以使用$_GET['foobar']来获取数据。