tags:

views:

63

answers:

4

I need to send 3 text box and one drop down value to a different page,I can not use the submit button i have to use the image. code:-

<table width="70%" border="0" align="right" cellpadding="0" cellspacing="5">
    <tr>
      <td width="11%" align="right" valign="middle" class="text6">Type:</td>
      <td width="12%" align="right" valign="middle" >
      <select name="type">
          <option value="Alumni">Alumni</option>
          <option value="Student">Student</option>
          <option value="Faculty">Faculty</option>    
      </select></td>
      <td width="7%" align="right" valign="middle" class="text6">Name</span>:</td>
      <td width="22%" align="right" valign="middle"><input type="text" name="name" id="name"  style="width:130px;"/></td>
      <td width="8%" align="right" valign="middle"class="text6" >Course/Department:</td>
      <td width="14%" align="right" valign="middle" ><input type="text" name="course"  style="width:90px;"/></td>
      <td width="5%" align="right" valign="middle"class="text6">Year:</td>
      <td width="12%" align="right" valign="middle"><input type="text" name="year" style="width:80px;"/></td>
      <td align="right" valign="middle"><a href="searchprocess.php?&name=value"><img src="images/search_box.jpg" width="60" height="25" border="0" align="middle" style="border: solid 1px #CCCCCC;" /></a></td>
    </tr>
</table>
+2  A: 

By adding more INPUT elements to the FORM. The browser will then add more key-value-pairs to the query string.

Aaron Digulla
yes to a different html page,but i have to use the href tag,there are 3 text box and one dropdown
mriganka3
Aaron Digulla
+1  A: 

Side note: Using anchor tag to submit form values is not recommended, better to use submit buttons.

But here's the answer: Use javascript. E.g.

<html>
...
<script type="text/javascript">
  function redirectWithValues() {
    var sStr = "../base/test.jsp?TEXT1=" + encodeURI(document.frmTest.TEXT1.value)
     + "&TEXT2=" + encodeURI(document.frmTest.TEXT2.value)
     + "&TEXT3=" + encodeURI(document.frmTest.TEXT3.value)
     + "&OPTION1=" + encodeURI(document.frmTest.OPTION1.value);

    window.location.href = sStr;
    return false;
  }
</script>
...
<form name="frmTest" action="../base/test.jsp">
  <input type="text" name="TEXT1" value="Value1" />
  <input type="text" name="TEXT2" value="Value2" />
  <input type="text" name="TEXT3" value="Value3" />
  <select name="OPTION1">
    <option value="OptionValue1">Option Description 1</option>
    <option value="OptionValue2">Option Description 2</option>
    <option value="OptionValue3">Option Description 3</option>
  </select>

  <a href="#" onclick="return redirectWithValues()">Woe is me</a>
</form>
...
</html>
Manny
A: 

New answer

Your original page can use the code you specified

<Form method="post" action="page2.php">
code for your table here....

<!--Submit Button as Image-->
<input type="image" src="images/yourimage.gif" alt="Submit Form" name="submit" />
</form>

page2.php could look something like this:

<html>
<body>

<?php
$type = $_POST['type'];
$name = $_POST['name'];
$course = $_POST['course'];
$year = $_POST['year'];

echo $type;

etc etc

?>
</body>
</html>

If you want to display it in a text box etc you would need to do something similar to this:

<input type="text" name="course" value="<?php echo $course; ?>" />

Original answer

Just submit the form using POST and handle the query string with some PHP on the next page.

This is assuming the data is not sensitive. I'd prefer PHP over Javascript (where possible).

Not sure your question is totally clear on what you are trying to do, and what technologies/languages are available to you.

Dan Harris
'll like to use php
mriganka3
I can not use the submit button,I have to use the image
mriganka3
Not sure what you mean by image, as you haven't yet mentioned anything about an image.Can you describe exactly what you're trying to achieve? Step by step what will the user do and see?
Dan Harris
Okay I see you have added the code to the question now. I will edit my answer
Dan Harris
+1  A: 

You can use <input type="image" ... /> instead of a submit button.

Sjoerd