Jump to content

multiple actions in one form

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
8 replies to this topic

#1
phpforfun

phpforfun

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,236 posts
First let me show you what im trying to do..

go to Under Construction! and go to google.com or whatever, then hover over favorites and click Add This Page, bookmark management should then popup, scroll down. see all the bookmarks? how you can edit them, change folders, delete them, what not, well that doesnt work yet, how do I make it so each one will perform there own action, even though all the input types have the same name? (delete, url, favtitle, favfolder)
Checkout my new forum! http://adminreference.com/

#2
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
<input type="text" name="url[]" />
That will submit an array, which you can then iterate through.

Edited by John, 23 May 2008 - 05:43 PM.


#3
phpforfun

phpforfun

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,236 posts
so...
<input type="text" value="1" name="url[]" />
<input type="text" value="2" name="url[]" />
<input type="text" value="3" name="url[]" />
<input type="text" value="4" name="url[]" />
<input type="text" value="5" name="url[]" />
and
Echo $url[];
would echo "12345"?

Edited by phpforfun, 23 May 2008 - 06:26 PM.

Checkout my new forum! http://adminreference.com/

#4
phpforfun

phpforfun

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,236 posts
im trying to get it to show multiple values... Its not working too well.

<form id="form1" name="form1" method="post" action="">


<input type="text"  name="url[]" /> 

<input type="checkbox" name="check[]" value="yes" /><br />

<input type="text"  name="url[]" />

<input type="checkbox" name="check[]" value="yes" /><br />

<input type="text"  name="url[]" /> 

<input type="checkbox" name="check[]" value="yes" /><br />

<input type="text"  name="url[]" />

<input type="checkbox" name="check[]" value="yes" /><br />

<input type="text"  name="url[]" />

<input type="checkbox" name="check[]" value="yes" /><br />

<input type="text"  name="url[]" />

<input type="checkbox" name="check[]" value="yes" /><br />

<input type="text"  name="url[]" />

<input type="checkbox" name="check[]" value="yes" /><br />


  <input type="submit" name="Submit" value="Submit" />

 

</form>

<?

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

	$url =  $_POST['url'];

	while(list($key,$value) = each($_POST['url'])){

		$num = $key + 1;

		$url2 = $value;

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

			$check = $_POST['check'];

			if($check[$num] === "yes"){

				Echo "$url2 checked<br>";

			} Else {

				Echo "$url2 unchecked<br>";

			}

		}

	}

}

?>

The test page is Untitled Document
I think its this line: if($check[$num] === "yes"){

Edited by phpforfun, 23 May 2008 - 06:51 PM.

Checkout my new forum! http://adminreference.com/

#5
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
Glad you got it. Out of curiosity, is there a reason you capitalize Echo?

Untested, but something like this should work:
if(isset($_POST['url'])){
    foreach($_POST['url'] as $url){
        echo $url;
    }
} 


#6
phpforfun

phpforfun

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,236 posts
Bunp, john, check the post above your last
Checkout my new forum! http://adminreference.com/

#7
phpforfun

phpforfun

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,236 posts
anyone know how I can get multiple values and pair them up?..
Checkout my new forum! http://adminreference.com/

#8
phpforfun

phpforfun

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,236 posts
I guess I could just make the values of the check box's the id of the bookmark, durr
Checkout my new forum! http://adminreference.com/

#9
ReekenX

ReekenX

    Programmer

  • Members
  • PipPipPipPip
  • 134 posts
What you searching, John have posted right answer for you!
www.jarmalavicius.lt | www.github.com/reekenx | www.twitter.com/reekenx