tags:

views:

125

answers:

4

For example, would like 5 checks boxes to have their own submit button and the other 5 to have their own submit. Should be independednt of each other but they are not grouped together in the html page.
Do I nest the other form? Do I put them under the same name and if so how do I distinct the submit? Submit seems to submit the form name element, not the elements names within the form. (Using HTML and JS)

Thanks.

A: 

I'd use the button element. Try this link: http://particletree.com/features/rediscovering-the-button-element/

Basically you use them as your submits. Firefox correctly sends the value attribute but IE sends the innerHTML. But they all come across as name=value/innerHTML.

So for example, using PHP, you could use

if (isset($_POST['nameOfButtonElement'])) {

echo 'user clicked this button';

}

EDIT: IE6 (surprise surprise) doesn't handle this correctly at all. See this question: http://stackoverflow.com/questions/567958/ie-6-and-the-multiple-button-elements-all-sending-their-name-values

alex
A: 

IainMH,

<form action="/cgi-bin/Lib.exe" method="post" name="checks" id="Form2">
  <input type="checkbox" name="user" value="'$NAME'" id="Checkbox1" />
  <input type="checkbox" name="user" value="'$NAME'" id="Checkbox2" />
  <input type="checkbox" name="guest" value="'$NAME'" id="Checkbox1" />
  <input type="checkbox" name="guest" value="'$NAME'" id="Checkbox2" />

  <input type="submit" value="DELETE" id="Submit1" name="Submit1" />
  <input type="submit" value="DELETE" id="Submit2" name="Submit2" />
</form>

Would like Submit1 to only be used to delete user's checkboxes and Submit2 for guest's checkboxes. I'm actually using JS to submit the form, as below:

document.checks.submit();
Tommy
A: 

Maybe something like that (this way you can control it):

function ava_aken_hp()
{
// I use blank form with hidden fields to populate it with values from POST.

  document.blank.action="https://www.mypage.com";
  document.blank.elements["CHECK"].value=....;
  ...
  document.blank.submit();
}

// In your form:
<input type="submit" value="Submit1" onclick="ava_aken_hp();">
Riho
+1  A: 

Your clarification doesn't make too much sense from a user standpoint. Perhaps you want something like this:

<form action="/cgi-bin/Lib.exe" method="post" name="checks" id="Form1">
  <input type="checkbox" name="user" value="'$NAME'" id="Checkbox1" />
  <input type="checkbox" name="user" value="'$NAME'" id="Checkbox2" />

  <input type="submit" value="DELETE" id="Submit1" name="Submit1" />
</form>

<form action="/cgi-bin/Lib.exe" method="post" name="checks" id="Form2">
  <input type="checkbox" name="guest" value="'$NAME'" id="Checkbox1" />
  <input type="checkbox" name="guest" value="'$NAME'" id="Checkbox2" />

  <input type="submit" value="DELETE" id="Submit2" name="Submit2" />
</form>
strager