Jump to content

Input Box Default Value Overwritten By Javascript Add Function


shanejeffery86

Recommended Posts

Hey all.

 

I am using the Smoothbox/Mootools JS libraries for a project.  Right now, I believe that I am just having a basic logic error, but it may be more than that.  Also, I am using Smarty for my templating system and HTML handling.

 

So, here is the issue.  I am trying to hit a JS function when 'My Friends' is clicked.  When the 'My Friends' is clicked, a Smoothbox window pops up and shows the data that I need it to show which is a couple of users' full names which are links.  If you click on one of those name links, it is supposed to append that name to the already existing list of invitees. 

 

In essence, I need the name that is clicked on the Smoothbox window to be added to the "invitees" ID input box.

 

TPL Code:

 

<td class="input_label"><label for="invitees">Invitee(s): </label></td>
<td><input type="text" id="invitees" name="invitees" value="{foreach from=$meetingUsers item=user}
{if $user.meeting_owner eq 0 && $user.fullname neq ''}{$user.fullname}; 
{elseif $user.meeting_owner eq 0}{$user.email}; {/if}{/foreach}" size="44" tabindex="1"></input>
<span style="padding-left: 20px;"><a href="" onClick="myFriendsList(); return false;">My Friends</a></span></td>

 

The myFriendsList() function pops up the Smoothbox window that shows the user names.  When one of those user names is clicked, the addToInviteeList() function is hit.

 

JS code:

 

function addToInviteeList(user_id, user_name) {
var invitee_list = document.getElementById('invitees').value;
var invitee_holder = document.getElementById('invitees');
invitee_holder.innerHTML = invitee_list + user_name + ';';
}

 

I believe that I am correct in assuming that the invitee_holder innerHTML value should overwrite the current text that is in the 'invitees' ID input box.  Is that correct?  Because when I click one of the user names, I get no JS error in my error console and I do not get the input box to take on the correct values.

 

Is it possible that the default value that is in there from Smarty is keeping the JS from running properly in the addToInviteeList() function?

 

I apologize if this is a jumble of thoughts.  I am just a little baffled as to what to do here.

 

Thanks.

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.