Jump to content

[SOLVED] Calling onLoad halfway down a page?


woolyg

Recommended Posts

Hi all,

 

I've got a piece of code that is half way down a PHP page. It calls a JS script, depending on whether a SESSION variable is set.

 


<?php
if((isset($_SESSION['one_to_many_input_choice']) && ($_SESSION['one_to_many_input_choice'] == "one_by_one"))){ // IF 27

$method_of_retrieval = "onload";

} else {

$method_of_retrieval = "onkeyup";

}
?>

 

 

Then..

 


<html>

<input name="number_of_recipients" id="number_of_recipients" <?php echo $method_of_retrieval; ?>="one_to_many_show_recipient_list()"/>

</html>

 

.. This essentially dictates the method of the one_to_many_show_recipient_list() call. If the SESSION variable is not set, the JS is called when the user types on their keyboard. If it is set, I'd like the page to automatically carry out the JS.

 

However, the 'onload' side of it doesn't want to work for me. Is there another way of automatically calling one_to_many_show_recipient_list() - similar to onload - without needing the user to physically do anything?

 

I hope I've been clear, I'm quite new to JS. All input appreciated.

Thanks,

WoolyG

 

 

Link to comment
Share on other sites

<?php
if((isset($_SESSION['one_to_many_input_choice']) && ($_SESSION['one_to_many_input_choice'] == "one_by_one")))
{ // IF 27
    $body_onload = ' onload="one_to_many_show_recipient_list();"';
    $input_onkeyup = '';
}
else
{
    $body_onload = '';
    $input_onkeyup = ' onkeyup="one_to_many_show_recipient_list();"';
}
?>

 

<html>
<body<?php echo $body_onload; ?>>
<input name="number_of_recipients" id="number_of_recipients"<?php echo $input_onkeyup; ?> />

</html>

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.