PDA

View Full Version : How I take the Data into JavaScript and return after some jobs


SorentoUltimate
01-27-2010, 09:44 PM
I put a new button at Creating Social Group Form and on click i run a JavaScript.

How can i read Form Fields data at JavaSript?

the form not use vBForm and $editorid !!!

Here the vBulletin Template

$stylevar[htmldoctype]
<html xmlns="http://www.w3.org/1999/xhtml" dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
$headinclude
<title>$vboptions[bbtitle] - $custompagetitle</title>
</head>
<body>
$header
$navbar

<if condition="!$icononly">
<form action="group.php?do=$action" method="post">
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
<input type="hidden" name="do" value="$action" />
<input type="hidden" name="groupid" value="$group[groupid]" />
<input type="hidden" name="url" value="$url" />

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="tcat">
$phrase
<if condition="$_REQUEST['do'] == 'edit'">
<span class="normal"><a href="group.php?$session[sessionurl]groupid=$group[groupid]">$group[name]</a></span>
</if>
</td>
</tr>
<tr>
<td class="panelsurround" align="center">
<div class="panel">
<table><tr><td align="$stylevar[left]">

<div class="smallfont">
<label for="socialgroupcategoryid">$vbphrase[social_group_category]:</label><br />
<select name="socialgroupcategoryid" id="socialgroupcategoryid">
<option value="">$vbphrase[select_a_category]</option>
$categoryoptions
</select>
</div>

<if condition="$show['title']">
<div class="smallfont">
<label for="groupname">$vbphrase[group_name]:</label><br />
<input type="text" class="bginput" name="groupname" id="groupname" size="50" maxlength="$vboptions[sg_name_maxchars]" value="$group[rawname]" tabindex="1" />
</div>
</if>

<div class="smallfont" style="margin-top:$stylevar[formspacer]px">
<label for="groupdescription">$vbphrase[group_description]: <span class="shade">($vbphrase[bbcode_not_allowed])</span></label><br />
<textarea class="bginput" name="groupdescription" id="groupdescription" cols="50" rows="5" tabindex="1">$group[rawdescription]</textarea>
</div>

<div class="smallfont" style="margin-top:$stylevar[formspacer]px">
<label for="grouptype">$vbphrase[group_type]:</label><br />
<select name="grouptype" id="grouptype">
<option value="public"$typeselected[public]>$vbphrase[group_type_public]</option>
<option value="moderated"$typeselected[moderated]>$vbphrase[group_type_moderated]</option>
<option value="inviteonly"$typeselected[inviteonly]>$vbphrase[group_type_inviteonly]</option>
</select>
</div>

<if condition="$show['options']">
<fieldset class="fieldset" style="margin-top:$stylevar[formspacer]px">
<legend>$vbphrase[group_options]</legend>
<div class="smallfont">
<if condition="$show['enable_group_albums']">
<div>
<label for="enable_group_albums"><input type="checkbox" name="options[enable_group_albums]" id="enable_group_albums" value="1" $checked[enable_group_albums]/> $vbphrase[enable_albums]</label>
</div>
</if>
<if condition="$show['enable_group_messages']">
<div>
<label for="enable_group_messages"><input type="checkbox" name="options[enable_group_messages]" id="enable_group_messages" value="1" $checked[enable_group_messages]/> $vbphrase[enable_messages]</label>
</div>
</if>
<if condition="$show['mod_queue']">
<div>
<label for="group_owner_mod_queue"><input type="checkbox" name="options[owner_mod_queue]" id="group_owner_mod_queue" value="1" $checked[mod_queue]/> $vbphrase[messages_must_be_approved_by_owner]</label>
</div>
</if>
<if condition="$show['join_to_view']">
<div>
<label for="join_to_view"><input type="checkbox" name="options[join_to_view]" id="join_to_view" value="1" $checked[join_to_view]/> $vbphrase[users_must_join_to_view_content]</label>
</div>
</if>
<if condition="$show['only_owner_discussions']">
<div>
<label for="only_owner_discussions"><input type="checkbox" name="options[only_owner_discussions]" id="only_owner_discussions" value="1" $checked[only_owner_discussions]/> $vbphrase[only_owner_can_create_new_discussions]</label>
</div>
<else />
<input type="hidden" name="options[only_owner_discussions]" id="only_owner_discussions" value="$checked[only_owner_discussions]" />
</if>
</div>
</fieldset>
</if>
</td></tr></table>
</div>

<div style="margin-top:$stylevar[cellpadding]px">
<input type="submit" value="$vbphrase[save]" class="button" accesskey="s" tabindex="1" />
<input type="reset" value="$vbphrase[reset]" class="button" />
</div>
</td>
</tr>
</table>

</form>
</if>

<if condition="$show[editicon]">
<if condition="!$icononly"><br /></if>


<form enctype="multipart/form-data" action="group.php?do=updateicon" method="post">
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
<input type="hidden" name="do" value="updateicon" />
<input type="hidden" name="groupid" value="$group[groupid]" />
<input type="hidden" name="icononly" value="$icononly" />

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="tcat" colspan="2"><if condition="$icononly">$vbphrase[create_group_icon]<else />$vbphrase[edit_group_icon]</if></td>
</tr>
<tr>
<td class="panelsurround" align="center">
<div class="panel">
<div style="width:$stylevar[formwidth_usercp]" align="$stylevar[left]">

<fieldset class="fieldset">
<legend>$vbphrase[current_group_icon]</legend>
<table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0">
<tr valign="top">
<if condition="!$groupiconurl">
<td class="alt1" style="border:1px inset; padding:$stylevar[cellpadding]px">
<span class="smallfont">$vbphrase[no_group_icon]</span>
</td>
<else />
<td class="smallfont">
<img src="$groupiconurl" alt="$vbphrase[current_group_icon]" border="0" style="margin-$stylevar[right]:8px;border:1px solid gray" />
</td>
</if>
<td class="smallfont">
<div style="margin-bottom:$stylevar[formspacer]px">$vbphrase[group_icon_desc]</div>
<if condition="$show['deleteicon']"><div style="margin-bottom:$stylevar[formspacer]px"><label for="groupicon"><input type="checkbox" name="deletegroupicon" value="1" id="groupicon" />$vbphrase[delete_current_image]</label></div></if>
</td>
</tr>
</table>
</fieldset>


<fieldset class="fieldset">
<legend>$vbphrase[custom_group_icon]</legend>

<div style="padding:$stylevar[formspacer]px">
<div class="fieldset">

$vbphrase[may_upload_custom_image_controls]<br /><br />

<if condition="$show['url_option']">
$vbphrase[enter_url_to_image]
<div style="padding:$stylevar[formspacer]px">
<input type="text" class="bginput" name="iconurl" value="http://www." size="45" dir="ltr" />
</div>
</if>

<if condition="$show['url_option']">$vbphrase[option_2_upload_image_from_computer]<else />$vbphrase[upload_image_from_computer]</if>
<div style="padding:$stylevar[formspacer]px">
<input type="file" class="bginput" name="upload" size="45" />
<input type="hidden" name="MAX_FILE_SIZE" value="$inimaxattach" />
</div>

$maxnote

</div>
</div>
</fieldset>

</div>
</div>

<div style="margin-top:$stylevar[cellpadding]px">
<input type="submit" class="button" value="$vbphrase[save_changes]" accesskey="s" />
<input type="reset" class="button" value="$vbphrase[reset_fields]" accesskey="r" />
<input type="submit" class="button" value="$vbphrase[skip]" name="skip" accesskey="p" />
</div>
</td>
</tr>
</table>

</form>
</if>

$footer
</body>
</html> ___


i want to take the groupname and the groupdescription.

kh99
01-27-2010, 11:07 PM
I'm not sure if I know what you're asking, but maybe this example will help? http://www.w3schools.com/js/tryit.asp?filename=tryjs_formvalidate

SorentoUltimate
01-28-2010, 11:56 PM
Thanks kh99,

for the Social Group Form work perfect!!!

but i do the same for Albums Edit and not work....

here the Albums Edit template

$stylevar[htmldoctype]
<html xmlns="http://www.w3.org/1999/xhtml" dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
$headinclude
$usercss
<title>$vboptions[bbtitle] - <if condition="$albuminfo['albumid']">$vbphrase[edit_album]<else />$vbphrase[add_album]</if></title>
</head>
<body>
$header
$navbar

<div id="usercss">

<if condition="$show['delete_option']">
<form action="album.php?do=killalbum&amp;albumid=$albuminfo[albumid]" method="post">
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
<input type="hidden" name="do" value="killalbum" />
<input type="hidden" name="albumid" value="$albuminfo[albumid]" />
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="tcat">
$vbphrase[delete_album]
</td>
</tr>
<tr>
<td class="panelsurround" align="center">
<div class="panel">
<div style="width:$stylevar[formwidth]" align="$stylevar[left]">
<div class="smallfont">
<span style="float: $stylevar[right]"><input type="submit" class="button" value="$vbphrase[delete_album]" accesskey="d" tabindex="1" /></span>
<input type="checkbox" name="delete" id="cb_delete" value="1" /><label for="cb_delete">$vbphrase[to_delete_this_album]</label></div>
</div>
</div>
</div>
</td>
</tr>
</table>
</form>

<br />
</if>

$errortable

<form action="album.php?do=updatealbum&amp;u=$userinfo[userid]&amp;albumid=$formdata[albumid]" method="post">
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="tcat">
<if condition="$albuminfo['title']">
<span class="smallfont normal" style="float: $stylevar[right]"><b>$vbphrase[album]</b>: <a href="album.php?$session[sessionurl]albumid=$albuminfo[albumid]">$albuminfo[title_html]</a></span>
</if>
<if condition="$albuminfo['albumid']">$vbphrase[edit_album]<else />$vbphrase[add_album]</if>
</td>
</tr>
<tr>
<td class="panelsurround" align="center">
<div class="panel">
<div style="width:$stylevar[formwidth]">
<table><tr><td align="$stylevar[left]">
<if condition="$show['album_used_in_css']">
<fieldset style="margin-bottom: $stylevar[cellpadding]px" class="fieldset">
<div class="smallfont" style="margin: $stylevar[cellpadding]px">
$vbphrase[album_pictures_used_profile_styling]
</div>
</fieldset>
</if>

<div class="smallfont">
$vbphrase[title]:
<div><input type="text" class="bginput" name="title" value="$formdata[title]" size="50" tabindex="1" /></div>
</div>

<div style="margin-top: $stylevar[cellpadding]px" class="smallfont">
$vbphrase[description]: <span class="shade">($vbphrase[bbcode_not_allowed])</span>
<div><textarea name="description" rows="5" cols="50" tabindex="1">$formdata[description]</textarea></div>
</div>

<div style="margin-top: $stylevar[cellpadding]px" class="smallfont">
$vbphrase[album_type]:
<div><label for="rb_albumtype_public"><input type="radio" name="albumtype" value="public" id="rb_albumtype_public" $formdata[albumtype_public] />$vbphrase[public]</label></div>
<div><label for="rb_albumtype_private"><input type="radio" name="albumtype" value="private" id="rb_albumtype_private" $formdata[albumtype_private] />$vbphrase[private_only_visible_contacts_moderators]</label></div>
<if condition="$show['albumtype_profile']"><div><label for="rb_albumtype_profile"><input type="radio" name="albumtype" value="profile" id="rb_albumtype_profile" $formdata[albumtype_profile] />$vbphrase[profile_pictures_modify_profile_style]</label></div></if>
</div>
</td></tr></table>
</div>
</div>

<div style="margin-top:$stylevar[cellpadding]px">
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
<input type="hidden" name="do" value="updatealbum" />
<input type="hidden" name="albumid" value="$formdata[albumid]" />
<input type="submit" class="button" value="$vbphrase[submit]" accesskey="s" tabindex="1" />
</div>
</td>
</tr>
</table>
</form>

</div>

$footer
</body>
</html>

the fields i want to take from here are title, description

but javascript cannot read title and description....

any idea???

kh99
01-29-2010, 12:33 AM
I think it may be because the tags for the title and description have no id attributes.

For example the delete checkbox has

<input type="checkbox" name="delete" id="cb_delete" value="1" />

but the title input field:

<input type="text" class="bginput" name="title" value="$formdata[title]" size="50" tabindex="1" />


has no id.

SorentoUltimate
01-29-2010, 01:14 AM
Thanks again,

if i add id's at templates it's ok or i will have other problems ???