Jump to content

desperate help needed with form action


helloise

Recommended Posts

i have this code in a foreach that lists  uniquecode links:

<a id="<?php echo $id_to ?>" href="<?php echo ADDRESS; ?>messageSent.php?id=<?php echo $id_to ?>" class="charcoal_link" style="line-height: 20px;" onclick="showMessageArea(this); return false;" >
    <?php echo $uniqueCode1?><span class="pink_text"><?php echo $uniqueCode2?></span><?php echo $uniqueCode3?>
</a>      
<form id="message_area" style="display:none"  method="post" action="<?php echo ADDRESS; ?>messageSent.php?id=<?php echo $id_to ?>">                                
     <textarea name="message" rows="10" cols="20"></textarea>
     <input name="Submit" type="submit" value="Send"></input>
</form>

 

this is what i get when i view the page source :

        <a href="http://www-rainbowcode-mobi/messageSent.php?id=36" class="charcoal_link" style="line-height: 20px;" onclick="showMessageArea(this); return false;" >

                                        KUZELJA<span class="pink_text">000</span>RC                                      </a>     

                                      <form id="message_area" style="display:none"  method="post" action="http://www-rainbowcode-mobi/messageSent.php?id=36">                               

                                        <textarea name="message" rows="10" cols="20"></textarea>

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

                                      </form>

                                                                      <a href="http://www-rainbowcode-mobi/messageSent.php?id=38" class="charcoal_link" style="line-height: 20px;" onclick="showMessageArea(this); return false;" >

                                        ALANZIM<span class="pink_text">000</span>RC                                      </a>     

                                      <form id="message_area" style="display:none"  method="post" action="http://www-rainbowcode-mobi/messageSent.php?id=38">                               

                                        <textarea name="message" rows="10" cols="20"></textarea>

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

                                      </form>

 

the problem is when the action fires and page goes to messageSent and i view page source again $id_to is NOT the id of the link i clicked on..it takes the first link's id regardless of which link i click on???

here the messageSent page source( i clicked on link with id 38 NOT 36):

where i have a print_r($_REQUEST) and it gives:

Array

(

    [id] => 36

    [message] => bj,nbgj,

    [submit] => Send

)

 

please urgent help needed...

thank you

Link to comment
Share on other sites

A) If you have an initial <form> tag (with out a closing </form> tag), before the start of your foreach(){} loop that outputs the code you did post, it will WIN and be the ?id= value that gets used when you submit any of the forms that would then be inside that initial form tag.

 

B) Your showMessageArea() javascript function or some other javascript you have on the page could have something to do with this, especially since you have assigned the same id="message_area" to every form (id's must be unique.)

 

C) Your messageSent.php code could be doing something to cause the value to be altered.

Link to comment
Share on other sites

thank you B) is the exact issue so i have altered my code like this:

function showMessageArea(link, id)
   {
      document.getElementById('message_id').value = id;
      var message_area = document.getElementById('message_area'); //if i concatenate id here to message_area it also does not get message area to show
      message_area = message_area+id;
      message_area.parentNode.removeChild(message_area);
      link.parentNode.insertBefore(message_area, link.nextSibling);
      message_area.style.display="block";
   }

 

where id is now the correct value of the link i clicked on and the link that gets paseds is also correct :

<a href="<?php echo ADDRESS; ?>messageSent.php?id=<?php echo $id_to; ?>" class="charcoal_link" style="line-height: 20px;" onclick="showMessageArea(this, '<?php echo $id_to; ?>'); return false;" >
      <?php echo $uniqueCode1;?><span class="pink_text"><?php echo $uniqueCode2;?></span><?php echo $uniqueCode3;?>
</a>      
<form id="message_area" style="display:none"  method="post" > 
<textarea name="message" rows="10" cols="20"></textarea>
<input name="Submit" type="submit" value="Send"></input>
<input type='hidden' name='id' id='message_id' value=""></input>
  </form>

 

the last little thing now is to get the message area an submit to show because it is STILL not showing :(

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.